Domanda di colloquio di TikTok

a tricky binary tree problem that took me 90min to solve