Tripadvisor interview question

binary tree related problems