232. Implement Queue using Stacks
題目:
https://leetcode.com/problems/implement-queue-using-stacks/
難度:
Easy
這個(gè)題沒(méi)有乖乖聽(tīng)話,因?yàn)楫?dāng)年做過(guò)用兩個(gè)stack來(lái)模擬queue
然后不得不說(shuō),我Python大法實(shí)在太厲害了
這功能強(qiáng)大的,我簡(jiǎn)直要嘖嘖嘖
class Queue(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.lst = []
def push(self, x):
"""
:type x: int
:rtype: nothing
"""
self.lst.append(x)
def pop(self):
"""
:rtype: nothing
"""
del self.lst[0]
def peek(self):
"""
:rtype: int
"""
return self.lst[0]
def empty(self):
"""
:rtype: bool
"""
return self.lst == []