Track Top-2 Maximum Among N Children

Asked at Nuro · Coding Questions · Difficulty: Easy

You are given `n` child nodes (e.g., in an N-ary tree). Each child has an integer value. While iterating through the `n` children, find the **largest** value and (if needed) the **second largest** value using a single pass that maintains two variables `max1` and `max2`.

Loading the problem…