Question d’entretien chez Amazon

some medium-difficulty binary tree problem