Amazon Interview Question

1. Leetcod question using tree structure.