TikTok interview question

How about the time complexity.