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))