TikTok interview question

The 4 questions are really basic. The fifth question is about constructing a binary tree.