generated from brightvarghese/22_ODD_DS_Exercise-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.py
45 lines (39 loc) · 1.02 KB
/
Main.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
40
41
42
43
44
45
import os
class Stack:
def __init__(self, size):
self.items = []
self.size = size
def is_empty(self):
# Write code here
if len(self.items)==0:
return True
else:
return False
def is_full(self):
# Write code here
if len(self.items)==self.size:
return True
else:
return False
def push(self, data):
if not self.is_full():
# Write code here
self.items.append(data)
def pop(self):
if not self.is_empty():
# Write code here
self.items.pop()
def status(self):
# Write code here
for element in self.items:
print(element)
# Do not change the following code
size, queries = map(int, input().rstrip().split())
stack = Stack(size)
for line in range(queries):
values = list(map(int, input().rstrip().split()))
if values[0] == 1:
stack.push(values[1])
elif values[0] == 2:
stack.pop()
stack.status()