leetle

Daily challenge for 2025-06-26

177. Implement Stack Using Queues

Write a function solve that simulates stack operations using queue operations. Given a list of operations, return the results. Operations are:
- ["push", x]: Push x to stack
- ["pop"]: Remove and return top element
- ["top"]: Return top element without removing
- ["empty"]: Return true if stack is empty

Example:
Input: [["push", 1], ["push", 2], ["top"], ["pop"], ["empty"]]
Output: [null, null, 2, 2, false]

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