알고리즘 with python/알고리즘 스터디
LeetCode 225. Implement Stack using Queues
정민됴
2024. 1. 4. 10:12
https://leetcode.com/problems/implement-stack-using-queues/
class MyStack:
def __init__(self):
self.q = []
def push(self, x: int) -> None:
self.q.append(x)
def pop(self) -> int:
return self.q.pop()
def top(self) -> int:
return self.q[-1]
def empty(self) -> bool:
return len(self.q)==0
queue를 이용하여 Stack을 만들어보는 자료구조 문제였다.