You are viewing a single comment's thread. Return to all comments →
Thanks, I was looking to optimize my C++ solution. I think you might enjoy using a for-each loop here:
void decode_huff(node * root,string s) { node* temp = root; for (char c : s) { temp = c == '0' ? temp->left : temp->right; if (temp->data) { cout << temp->data; temp = root; } } }
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 →
Thanks, I was looking to optimize my C++ solution. I think you might enjoy using a for-each loop here: