6
0
:0
0
Tree Floor Enumeration
Tree Floor Enumeration
Easy
Trees
In "Tree Floor Enumeration", the binary tree is provided in array form (level-order with null gaps).
Return node values grouped by depth from top to bottom and left to right.
Example 1
Input:
root = [15,16,17,null,18,19,null]Output:
[[15],[16,17],[18,19]]For input root = [15,16,17,null,18,19,null], nodes are grouped by depth from top to bottom, yielding [[15],[16,17],[18,19]]. Therefore, return [[15],[16,17],[18,19]].
Example 2
Input:
root = [25,26,27,28,null,null,29]Output:
[[25],[26,27],[28,29]]For input root = [25,26,27,28,null,null,29], nodes are grouped by depth from top to bottom, yielding [[25],[26,27],[28,29]]. Therefore, return [[25],[26,27],[28,29]].
Constraints
0 <= number of nodes <= 2000-1000 <= Node.val <= 1000
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[15,16,17,null,18,19,null]Expected Output:
[[15],[16,17],[18,19]]Test Case 2
Input:
[25,26,27,28,null,null,29]Expected Output:
[[25],[26,27],[28,29]]