Amazon Interview Question

Coding tree functions