【leetcode】114. 二叉树展开为链表
void flatten(struct TreeNode* root) { struct TreeNode* curr = root; while (curr != NULL) { if (curr->left != NULL) { struct TreeNode* next = curr->left; struct TreeNode* predecessor = next; while (predecessor->right != NULL) { predecessor = predecessor->right; } predecessor->right = curr->right; curr->left = NULL; curr->right = next; } curr = curr->right; } }