Skip to content

Instantly share code, notes, and snippets.

void encode_word(string &s) {
encode_word_helper(s, 0);
}
void encode_word_helper(string &s, int i) {
if (i == s.size()) {
cout << reduce(s) << endl;
return;
}
void mutate_tree_bfs(const shared_ptr<BinaryTree> &root) {
stack<shared_ptr<BinaryTree>> stack1;
stack<shared_ptr<BinaryTree>> stack2;
stack<shared_ptr<BinaryTree>> *st1 = &stack1;
stack<shared_ptr<BinaryTree>> &st2 = &stack2;
st1->push(root);
shared_ptr<BinaryTree> *temp = nullptr;
bool is_left_most = true;
void mutate_binary_tree(const shared_ptr<BinaryTree> &root) {
if (!root) {
return;
}
mute_dfs_post_order(root);
shared_ptr<BinaryTree> n = root;
while (n->left) {
auto current = n;
auto next = current->left;
next = get_right_most(next);