You are viewing a single comment's thread. Return to all comments →
I had a similar solution, but refactored out one while loop (and changed the other to for-in) based on comments here.
def decodeHuff(root, s): curr = root result = '' for i in s: if i == '0': curr = curr.left else: curr = curr.right if not curr.left and not curr.right: result += curr.data curr = root print(result)
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
I had a similar solution, but refactored out one while loop (and changed the other to for-in) based on comments here.