Binary Tree Level Order Traversal from Right to Left
Easy
Question
Given the root of a tree, return a list of lists of the node values in the tree in level order traversal from right to left (top to bottom, right to left).
Input: root = [1, 2, 3, 4, None, 6, 7]
Output: [[1], [3, 2], [7, 6, 4]]
Input: root = [5, 9, None]
Output: [[5], [9]]
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
What is the expected output if the given tree is the following? [10, 5, 15, 3, 7, None, 18]
[[10], [5, 15], [3, 7, 18]]
[[10], [5, 15], [18, None, 7, 3]]
[[18, 7, 3], [15, 5], [10]]
[[10], [15, 5], [18, 7, 3]]
Take a moment to understand the problem and think of your approach before you start coding.