TikTok Interview Question

2 leetcode style, 1 Hard (Dynamic Programming) and the other is Medium (Simulation).