Amazon Interview Question

some binary tree related