Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#40 from theycallmemac/patch-1
Browse files Browse the repository at this point in the history
Create __init__.py
  • Loading branch information
harshildarji authored Oct 14, 2016
2 parents 6bff826 + 4eddeb9 commit 9b054f5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions data_structures/Stacks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Stack:

def __init__(self):
self.stack = []
self.top = 0

def is_empty(self):
return self.top == 0

def push(self, item):
if self.top < len(self.stack):
self.stack[self.top] = item
else:
self.stack.append(item)

self.top += 1

def pop(self):
if self.is_empty():
return None
else:
self.top -= 1
return self.stack[self.top]

0 comments on commit 9b054f5

Please sign in to comment.