Skip to content

Instantly share code, notes, and snippets.

@wenweixu
Created September 2, 2019 04:33
Show Gist options
  • Save wenweixu/ac33cea275f3ef3c444fbf8f5add3a89 to your computer and use it in GitHub Desktop.
Save wenweixu/ac33cea275f3ef3c444fbf8f5add3a89 to your computer and use it in GitHub Desktop.
Hackerrank Huffman Decoding Python solution
def decodeHuff(root, s):
current = root
result = ''
for code in s:
if int(code) == 0:
current = current.left
else:
current = current.right
if current.left == None and current.right == None:
result += current.data
current = root
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment