File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # https://leetcode.cn/problems/plus-one
2
+
3
+
4
+ class MyStack :
5
+ '''
6
+ Date: 2023.08.04
7
+ Pass/Error/Bug: 1/0/0
8
+ 执行用时: 48 ms, 在所有 Python3 提交中击败了 22.37% 的用户
9
+ 内存消耗:15.64 MB, 在所有 Python3 提交中击败了 62.97% 的用户
10
+ '''
11
+ def __init__ (self ):
12
+ self .stack = []
13
+
14
+ def push (self , x : int ) -> None :
15
+ self .stack .append (x )
16
+
17
+ def pop (self ) -> int :
18
+ x = self .stack [- 1 ]
19
+ self .stack = self .stack [:- 1 ]
20
+ return x
21
+
22
+ def top (self ) -> int :
23
+ return self .stack [- 1 ]
24
+
25
+ def empty (self ) -> bool :
26
+ if len (self .stack ) == 0 :
27
+ return True
28
+ else :
29
+ return False
30
+
31
+
32
+
33
+ # Your MyStack object will be instantiated and called as such:
34
+ # obj = MyStack()
35
+ # obj.push(x)
36
+ # param_2 = obj.pop()
37
+ # param_3 = obj.top()
38
+ # param_4 = obj.empty()
You can’t perform that action at this time.
0 commit comments