As reported: Autodesk Pune Software Engineer loop (C++, 2026), round 1: level-order traversal of a binary tree, printing each level on a new line; followed by Rotting Oranges. C++ concepts were probed deeply throughout.
This is LeetCode 102 — Binary Tree Level Order Traversal.
Given the root of a binary tree, return its nodes' values level by level: a list per level, from the root level down, each level left to right. (Printing each returned list on its own line gives the "one level per line" output.)
Example 1
root = [3,9,20,null,null,15,7] -> [[3],[9,20],[15,7]]
Example 2
root = [1] -> [[1]]
Example 3
root = [] -> []
Constraints: the number of nodes is in [0, 2000]; -1000 ≤ Node.val ≤ 1000.
Code runner format: one line holding the tree in LeetCode's level-order array form (null for missing children). Implement levelOrder(root); the harness prints the list of levels.