forked from super30admin/PreCourse-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exercise_1.py
39 lines (31 loc) · 836 Bytes
/
Exercise_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Time Complexity :
# Space Complexity :
# Did this code successfully run on Leetcode :
# Any problem you faced while coding this :
# implement stack using array
class myStack:
# Please read sample.java file before starting.
# Kindly include Time and Space complexity at top of each file
def __init__(self):
self.stack = []
def isEmpty(self):
return self.stack == []
def push(self, item):
self.stack.append(item)
def pop(self):
if (not self.isEmpty()):
elem = self.stack[-1]
del (self.stack[-1])
else:
return ("Empty Stack")
# def peek(self):
def size(self):
return len(self.stack)
def show(self):
return self.stack
s = myStack()
s.push('1')
s.push('2')
print(s.show())
print(s.pop())
print(s.show())