Назад к задачам
Условие задачи

Implement a FIFO queue data structure while relying solely on two stack instances. The queue should expose the typical operations:

  • push(x) — adds element x to the tail of the queue;
  • pop() — removes and returns the element at the head of the queue;
  • peek() — returns the head element without removing it;
  • empty() — returns True if the queue has no elements, otherwise False.
class SimpleStack:
    def __init__(self):
        pass

    def push(self, value: int):
        pass

    def pop(self) -> int:
        pass

    def peek(self) -> int:
        pass

    def empty(self) -> bool:
        pass