class Solution {
public void flatten(TreeNode root) {
if (root == null) return;
flatten(root.left);
flatten(root.right);
TreeNode left = root.left;
TreeNode right = root.right;
root.left = null;
root.right = left;
TreeNode p = root;
while(p.right != null){
p = p.right;
}
p.right = right;
}
}
leetcode 114
最新推荐文章于 2022-07-28 10:23:30 发布