Skip to content
6
0
:
0
0

Server Rack Level Scan: Game Skill Tree Edition

Hard

Trees

In "Server Rack Level Scan: Game Skill Tree Edition", 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 = [23,24,25,null,26,27,null]
Output:[[23],[24,25],[26,27]]

For input root = [23,24,25,null,26,27,null], nodes are grouped by depth from top to bottom, yielding [[23],[24,25],[26,27]]. Therefore, return [[23],[24,25],[26,27]].

Example 2

Input:root = [33,34,35,36,null,null,37]
Output:[[33],[34,35],[36,37]]

For input root = [33,34,35,36,null,null,37], nodes are grouped by depth from top to bottom, yielding [[33],[34,35],[36,37]]. Therefore, return [[33],[34,35],[36,37]].

Constraints

  • 0 <= number of nodes <= 2000
  • -1000 <= Node.val <= 1000
solution.js
Loading...

Test Cases (2)

Test Case 1
Input:
[23,24,25,null,26,27,null]
Expected Output:
[[23],[24,25],[26,27]]
Test Case 2
Input:
[33,34,35,36,null,null,37]
Expected Output:
[[33],[34,35],[36,37]]