Yandex Interview Question

LeetCode medium question on binary tree