프로그래밍/HackerRank
[HackerRank][Python3] Tree: Huffman Decoding
snoopybox
2018. 7. 20. 22:41
Problem :
https://www.hackerrank.com/challenges/tree-huffman-decoding/problem
My Solution :
#!/usr/bin/env python3 def decodeHuff(root, s): decoded = [] curr = root for ch in s: if ch == '1': curr = curr.right else: curr = curr.left if curr.data != '\0': decoded.append(curr.data) curr = root print(''.join(decoded))