Google interview question

Tree traversal leetcode style question,