Daily challenge for 2026-05-17
502. Clear the Backlog
You are managing a task queue. You are given a list of integers representing tasks. A positive integer represents adding a task of that priority to your stack, while a zero represents completing the most recently added task (the one on top of the stack). Return the priority of the last task remaining in the stack after all operations are processed. If the stack is empty at the end, return -1. You may assume that a zero will only appear if there is at least one task in the stack.
Example:Input: tasks = [5, 10, 0, 3]Output: 3
Explanation: Add 5, add 10, remove 10 (because of 0), add 3. The stack is [5, 3]. The last task is 3.
Run this challenge interactively in Python or JavaScript when the app loads.