파비의 매일매일 공부기록

Today's Challenge 본문

Problem Solving/LeetCode

Today's Challenge

fabichoi 2022. 5. 5. 23:45

https://leetcode.com/problems/implement-stack-using-queues

 

Implement Stack using Queues - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

오늘 문제는 매우 간단쓰..
그냥 list 이용해서 풀면 매우 간단하게 해결된다.

class MyStack:

    def __init__(self):
        self.st = []

    def push(self, x: int) -> None:
        self.st.append(x)
        

    def pop(self) -> int:
        return self.st.pop()
        

    def top(self) -> int:
        return self.st[-1]
        

    def empty(self) -> bool:
        return not self.st
반응형

'Problem Solving > LeetCode' 카테고리의 다른 글

Today's Challenge  (0) 2022.05.07
Today's Challenge  (0) 2022.05.06
Today's Challenge  (0) 2022.05.04
Today's Challenge  (0) 2022.05.03
Today's Challenge  (0) 2022.05.02
Comments