TikTok interview question

A Leetcode dynamic programming question