Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).
Intuition
DFS
We use layer to track current node’s depth. We insert values from top to bottom and from left to right by visiting left subtree before right subtree.
BFS
We use a queue to track all nodes at the current level. For each level, we process all nodes in the queue: extract their values and add their children to the queue for the next level.