TikTok interview question

Algorithm Test is Puzzle 9 question