Skip to content

Instantly share code, notes, and snippets.

@ttowncompiled
ttowncompiled / settings.json
Created May 26, 2017 19:30
VS Code user settings
// Overwrite settings by placing them into your settings file.
// See http://go.microsoft.com/fwlink/?LinkId=808995 for the most commonly used settings.
{
// Editor
// Controls the font family.
"editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace",
// Controls the font weight.
@ttowncompiled
ttowncompiled / BinarySearchTree.py
Last active May 21, 2017 07:38
A BinarySearchTree to use for HackerRank problems.
###
# Python 3
# T = [int, BinarySearchTree, BinarySearchTree, int] or None
###
def size(T):
return T[3] if not T is None else 0
def is_empty(T):
return T is None
def v(T):
return T[0]
@ttowncompiled
ttowncompiled / Stack.py
Last active May 21, 2017 06:49
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
@ttowncompiled
ttowncompiled / Queue.py
Last active May 21, 2017 06:50
A Queue implemented with 2 stacks to use for HackerRank problems.
###
# Python 3
# Q = [ [], [] ]
###
def size(Q):
return len(Q[0]) + len(Q[1])
def is_empty(Q):
return (len(Q[0]) + len(Q[1])) == 0
def peek(Q):
if len(Q[1]) == 0:
@ttowncompiled
ttowncompiled / MaxHeap.py
Last active May 21, 2017 06:42
A Max Heap to use for HackerRank problems.
###
# Python 3 - MinHeap
# H = []
###
def size(H):
return len(H)
def is_empty(H):
return len(H) == 0
def peek(H):
return H[0] if len(H) > 0 else None
@ttowncompiled
ttowncompiled / MinHeap.py
Last active May 21, 2017 06:42
A MinHeap to use for HackerRank problems.
###
# Python 3 - MinHeap
# H = []
###
def size(H):
return len(H)
def is_empty(H):
return len(H) == 0
def peek(H):
return H[0] if len(H) > 0 else None