TikTok Interview Question

How to code a problem.