largestValues
to store the result.currMax
to the smallest possible integer value.
c. Iterate over the nodes at the current level:
i. Dequeue a node from the queue.
ii. Update currMax
if the current node's value is greater.
iii. Enqueue the node's children if they exist.
d. After processing all nodes at the current level, add currMax
to largestValues
.largestValues
list.