TikTok Interview Question

dynamic programming and other algorithm.