TikTok interview question

coding assessment - leet code hard