O33

Implement Stack using Queues

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: ARRAY

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) -> list

Input & 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ır

Example 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]
Loading Python Editor...
Input Parameters
[
  [
    [
      "push",
      1
    ],
    [
      "push",
      2
    ],
    [
      "top"
    ],
    [
      "pop"
    ],
    [
      "empty"
    ]
  ]
]
Expected Output
[
  null,
  null,
  2,
  2,
  false
]