leetcode 114. Flatten Binary Tree to Linked List

来源:互联网 发布:redcountdown.js 编辑:程序博客网 时间:2024/06/07 07:01

Morris Traversal

class Solution {public:void flatten(TreeNode* root){while (root){if (root->left){auto p = root->left;while (p->right){p = p->right;}p->right = root->right;root->right = root->left;root->left = nullptr;}root = root->right;}}};


0 0
原创粉丝点击