Skip to content

Instantly share code, notes, and snippets.

@cs-fedy
Created August 4, 2020 06:41
Show Gist options
  • Save cs-fedy/60e8fc6c30e3979fad6b37bdc0648e57 to your computer and use it in GitHub Desktop.
Save cs-fedy/60e8fc6c30e3979fad6b37bdc0648e57 to your computer and use it in GitHub Desktop.
stack implementation using list in python.
class ListStack:
def __init__(self):
self.stack = []
def is_empty(self):
return not self.stack
def get_peek(self):
assert(not self.is_empty())
return self.stack[-1]
def push(self, key):
self.stack.append(key)
def pop(self):
self.stack.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment