We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7198914 commit 49b35b9Copy full SHA for 49b35b9
Target Offer/用两个队列实现栈.py
@@ -7,9 +7,7 @@ def __init__(self):
7
self.queue1 = []
8
self.queue2 = []
9
def push(self, x):
10
- if self.queue1 == [] and self.queue2 == []:
11
- self.queue1.append(x)
12
- elif self.queue1 != [] and self.queue2 == []:
+ if self.queue2 == []:
13
self.queue1.append(x)
14
else:
15
self.queue2.append(x)
@@ -36,4 +34,4 @@ def pop(self):
36
34
print(P.pop())
37
35
38
39
-print(P.pop())
+print(P.pop())
0 commit comments