Question d’entretien chez TikTok

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