TikTok interview question

just do the leetcode. it 's 909