6
0
:0
0
Cluster Node Level Trace
Cluster Node Level Trace
Medium
Trees
In "Cluster Node Level Trace", 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 = [7,8,9,null,10,11,null]Output:
[[7],[8,9],[10,11]]For input root = [7,8,9,null,10,11,null], nodes are grouped by depth from top to bottom, yielding [[7],[8,9],[10,11]]. Therefore, return [[7],[8,9],[10,11]].
Example 2
Input:
root = [17,18,19,20,null,null,21]Output:
[[17],[18,19],[20,21]]For input root = [17,18,19,20,null,null,21], nodes are grouped by depth from top to bottom, yielding [[17],[18,19],[20,21]]. Therefore, return [[17],[18,19],[20,21]].
Constraints
0 <= number of nodes <= 2000-1000 <= Node.val <= 1000
solution.js
Loading...
Test Cases (2)
Test Case 1
Input:
[7,8,9,null,10,11,null]Expected Output:
[[7],[8,9],[10,11]]Test Case 2
Input:
[17,18,19,20,null,null,21]Expected Output:
[[17],[18,19],[20,21]]