TikTok Interview Question

just do the leetcode. it 's 909