Amazon interview question

basic of trees and stacks