Skip to content

Instantly share code, notes, and snippets.

@ttowncompiled
Last active May 21, 2017 06:49
Show Gist options
  • Save ttowncompiled/4d433644878bb082ed5261dd4b035ac0 to your computer and use it in GitHub Desktop.
Save ttowncompiled/4d433644878bb082ed5261dd4b035ac0 to your computer and use it in GitHub Desktop.
A Stack to use for HackerRank problems.
###
# Python 3
# S = []
###
def size(S):
return len(S)
def is_empty(S):
return len(S) == 0
def peek(S):
return S[-1] if len(S) > 0 else None
def push(S, x):
S.append(x)
def pop(S):
return S.pop() if len(S) > 0 else None
# The End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment