-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistogram.py
More file actions
34 lines (28 loc) · 784 Bytes
/
Histogram.py
File metadata and controls
34 lines (28 loc) · 784 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
class stack:
data = []
def __init__(self): # Constructor
data = [] # list - instance vaiable
self.top = -1 # top - instance variable
def size(self): # getter funciton - size
return len(self.data) # length - of data
def peek(self):
return self.data(self.top)
def push(self,item):
self.data.append(item)
self.top += 1
def pop(self):
rev = self.data.pop(self.top)
self.top -= 1
return rev
def isEmpty(self):
return len(self.data) == 0
def display(self):
print(self.data)
n = int(input())
s = stack()
a=[]
for i in range(0, n):
a.append(int(input()))
var ,ans, mx, i = 0, 0, 0, 0
while i < len(a):
if s.isEmpty() or