data_structures.stacks.stack_using_two_queues

Attributes

stack

Classes

StackWithQueues

https://www.geeksforgeeks.org/implement-stack-using-queue/

Module Contents

class data_structures.stacks.stack_using_two_queues.StackWithQueues

https://www.geeksforgeeks.org/implement-stack-using-queue/

>>> stack = StackWithQueues()
>>> stack.push(1)
>>> stack.push(2)
>>> stack.push(3)
>>> stack.peek()
3
>>> stack.pop()
3
>>> stack.peek()
2
>>> stack.pop()
2
>>> stack.pop()
1
>>> stack.peek() is None
True
>>> stack.pop()
Traceback (most recent call last):
    ...
IndexError: pop from an empty deque
peek() int | None
pop() int
push(item: int) None
main_queue: collections.deque[int]
temp_queue: collections.deque[int]
data_structures.stacks.stack_using_two_queues.stack: StackWithQueues | None