>_
level_order.scala
Scala 3.6
Not run yet

+ 7 hidden

Input
root = [6, 2, 9, 1, 4, null, 12]
Expected
[[6], [2, 9], [1, 4, 12]]

The root 6 is a level of its own, its children 2 and 9 form the next one, and the grandchildren 1, 4 and 12 the last. 9 has no left child, so the third level simply has three values.