Daily challenge for 2026-06-14
530. Clear the Smaller Neighbors
You are given a list of integers. You process the list from left to right. For each number, if it is strictly greater than the number currently at the top of your stack, you remove (pop) the top of the stack because it is 'overshadowed'. You then push the current number onto the stack. If the current number is less than or equal to the top of the stack, you simply push it. Return the final state of the stack.
Example:Input: nums = [3, 1, 4, 2]Output: [4, 2]
Explanation: 3 is pushed. 1 is pushed (1 <= 3). 4 is greater than 1, so 1 is popped. 4 is greater than 3, so 3 is popped. 4 is pushed. 2 is pushed (2 <= 4).
Run this challenge interactively in Python or JavaScript when the app loads.