Amazon Interview Question

a lot of tree problems