Skip to content

Commit f6cb696

Browse files
author
Amogh Singhal
authored
Create stack_data_structure.py
1 parent d642f6d commit f6cb696

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

stack_data_structure.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Stack:
2+
def __init__(self):
3+
self.stack = []
4+
5+
def push(self, value):
6+
self.stack.append(value)
7+
8+
def pop(self):
9+
if self.isEmpty():
10+
print("Stack underflow...")
11+
return None
12+
else:
13+
self.stack.pop()
14+
15+
def size(self):
16+
return len(self.stack)
17+
18+
def isEmpty(self):
19+
return self.size() == 0
20+
21+
def peek(self):
22+
if self.isEmpty():
23+
return None
24+
else:
25+
return self.stack[-1]

0 commit comments

Comments
 (0)