error: cannot solve it. use a previous node to store last inorder variable, then perform inroder traverse. pattern: inorder(root-left); prev-left = root; root-right = prev; prev = root; inorder(root-right);
error:
cannot solve it.
- use a previous node to store last inorder variable, then perform inroder traverse.
pattern:
inorder(root->left);
prev->left = root;
root->right = prev;
prev = root;
inorder(root->right);