TikTok Interview Question

I could not pass the coding round