Amazon Interview Question

Tree Based Question and One basic Math's.