You are viewing a single comment's thread. Return to all comments →
Tear my Java solution to pieces and tell me how it could be improved :D
void decode(String S, Node root) { StringBuilder sb = new StringBuilder(); Node c = root; for (int i = 0; i < S.length(); i++) { c = S.charAt(i) == '1' ? c.right : c.left; if (c.left == null && c.right == null) { sb.append(c.data); c = root; } } System.out.print(sb); }
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 →
Tear my Java solution to pieces and tell me how it could be improved :D