We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defdecodeHuff(root:Node,s:str)->None:result=[]curr=root#startpointeratrootnodefordigitins:curr=curr.leftifdigit=="0"elsecurr.right# if a leaf node is reached, append its character to decoded # string result, and reset pointer back to root of treeifnotall([curr.left,curr.right]):#equivalentto`isnotNone`result.append(curr.data)curr=rootprint("".join(result))
Instructions should have been clearer on the "output" of the function either returning or printing the string.
Cookie support is required to access HackerRank
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 →
Python solution:
Instructions should have been clearer on the "output" of the function either returning or printing the string.