Amazon Interview Question

some medium-difficulty binary tree problem