Amazon Interview Question

Leetcode hard problem on trees.