We’re preparing your current view and syncing the latest data.
Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
Example:
Given binary tree [3,9,20,null,null,15,7],
3
/
9 20
/
15 7
return its level order traversal as: [ [3], [9,20], [15,7] ]
The input is the root node of a binary tree. Each node contains an integer value, and pointers to left and right child nodes, or null if no child exists.
Return a list of lists of integers, representing each level's node values from left to right.
The number of nodes in the tree is in the range [0, 10^4]. -10^5 <= Node.val <= 10^5
Example 1
Input
[3,9,20,null,null,15,7]
Output
[[3],[9,20],[15,7]]
Explanation
The tree is traversed level by level: first root 3, then nodes 9 and 20, then nodes 15 and 7.