O33
Implement Stack using Queues
Problem Statement & Objective
Implement a last-in-first-out (LIFO) stack using only standard FIFO queue operations.
Function Signature (Python)
stack_using_queues(operations: list) -> listInput & Output Contract
Output Rule:İşlem sonuçları listesi (None, sayı, boolean).
System Constraints
1 <= islemler.length <= 100
1 <= val <= 9
pop ve top çağrıları boş olmayan yapıda yapılırExample Execution Walkthrough
islemler = [['push', 1], ['push', 2], ['top'], ['pop'], ['empty']]
cevap: [None, None, 2, 2, False]Example Test Scenarios (3)
Example 1
Input:
[[["push",1],["push",2],["top"],["pop"],["empty"]]]Expected Output:
[null,null,2,2,false]Example 2
Input:
[[["push",5],["pop"],["empty"]]]Expected Output:
[null,5,true]Example 3
Input:
[[["push",10],["top"]]]Expected Output:
[null,10]