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).
Return the result as a list of lists, where each inner list contains the node values at that depth level.
Each node has a val (integer value), a left child, and a right child. Children may be null.
The tree is given as a level-order array where null represents a missing node. For example, [3,9,20,null,null,15,7] represents:
3
/ \
9 20
/ \
15 7
root = [3, 9, 20, null, null, 15, 7][[3], [9, 20], [15, 7]]root = [1][[1]]root = [][]The number of nodes in the tree is in the range [0, 2000]-1000 <= Node.val <= 1000Expected time complexity: O(n)Run your code to see results
Use Cmd+Enter to run