TikTok interview question

Leetcode question 208 was asked