You are viewing a single comment's thread. Return to all comments →
From my HackerRank solutions.
void decode(String str, Node root) { Node n = root; for (int i = 0; i < str.length(); i++) { n = str.charAt(i) == '0' ? n.left : n.right; if (n.left == null && n.right == null) { System.out.print(n.data); n = root; } } }
Let me know if you have any questions.
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
Java solution - passes 100% of test cases
From my HackerRank solutions.
Let me know if you have any questions.