public void flatten(TreeNode root) { if(root == null){ return; }else{ if(root.left == null){ flatten(root.right); }else{ TreeNode node = root; TreeNode nodeRight = root.right; node.right = root.left; root.left = null; while(node.right != null){ node = node.right; } node.right = nodeRight; flatten(root.right); } } }
——2020.6.20