leetle

Daily challenge for 2026-05-10

495. Clear the Warehouse Shelves

You are managing a warehouse shelf where items are represented by integers. A robotic arm processes the shelf from left to right. If the robotic arm encounters an item that is exactly one unit larger than the item it just picked up, it considers them a 'matching pair' and removes the previous item from its temporary bin instead of adding the new one. If the items do not match this criteria, the new item is added to the bin. Return the final state of the items in the bin.

Example:
Input: items = [1, 2, 5, 6, 4]
Output: [4]
(Explanation: 2 is 1+1, so 1 is removed, but wait, the logic is: if item == stack[-1] + 1, pop stack, don't add item. So for [1, 2, 5, 6, 4]: stack=[1], item=2 -> pop 1, stack=[]. item=5 -> stack=[5]. item=6 -> pop 5, stack=[]. item=4 -> stack=[4]. Output: [4])

Run this challenge interactively in Python or JavaScript when the app loads.