Domanda di colloquio di TikTok

I forgot, but had to do with a binary tree