Created
August 4, 2020 06:41
-
-
Save cs-fedy/60e8fc6c30e3979fad6b37bdc0648e57 to your computer and use it in GitHub Desktop.
stack implementation using list in python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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