public class Solution { public TreeNode Convert(TreeNode root) { if(root == null){ return null; } TreeNode newHead = root; TreeNode pre; if(root.left != null){ //排序左边 newHead = Convert(root.left); pre = newHead; while(pre.right != null){ pre = pre.right; } pre.right = root; root.left = pre; } if(root.right != null){//排序右边 pre = Convert(root.right); pre.left = root; root.right = pre; } return newHead; } }