标签:二叉搜索树 ret while solution public 双向 code treenode color
public class Solution {
public TreeNode Convert(TreeNode pRootOfTree) { if(pRootOfTree == null) return null; if(pRootOfTree.left==null&&pRootOfTree.right==null) return pRootOfTree; TreeNode left = Convert(pRootOfTree.left); TreeNode p = left; while(p != null&&p.right!=null){ p = p.right; } if(p!=null) { p.right = pRootOfTree; pRootOfTree.left = p; } TreeNode right = Convert(pRootOfTree.right); if(right!=null){ pRootOfTree.right = right; right.left = pRootOfTree; } return left!=null?left:pRootOfTree; } }
标签:二叉搜索树 ret while solution public 双向 code treenode color
原文地址:https://www.cnblogs.com/zhwcs/p/10453661.html