-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
38 lines (31 loc) · 782 Bytes
/
stack.py
File metadata and controls
38 lines (31 loc) · 782 Bytes
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
class Stack:
start = 0
rear = 0
dic = {}
def push(self, value):
self.rear += 1
self.dic[self.rear] = value
return self.start, self.rear, self.dic, value
def pop(self):
popvalue = self.dic[self.rear]
del self.dic[self.rear]
self.rear -= 1
return self.dic, popvalue
def size(self):
return self.dic, (self.rear - self.start)
# s = Stack()
# print(s.push(21))
# print(s.size())
# print(s.push(33333))
# print(s.size())
# print(s.push(45435))
# print(s.pop())
# print(s.size())
print("NEW SSSSSSSTACK()s for every single line")
print(Stack().push(21))
print(Stack().size())
print(Stack().push(33333))
print(Stack().size())
print(Stack().push(45435))
print(Stack().pop())
print(Stack().size())