标签:sub == tle 转换 res 序列 his 中序遍历 node
1 /** 2 public class TreeNode { 3 int val = 0; 4 TreeNode left = null; 5 TreeNode right = null; 6 7 public TreeNode(int val) { 8 this.val = val; 9 10 } 11 12 } 13 */ 14 15 16 public class Solution { 17 18 TreeNode head = null; 19 TreeNode res = null; 20 21 public TreeNode Convert(TreeNode TreeNode) { 22 23 InOrder(TreeNode); 24 return res; 25 26 27 28 } 29 30 private void InOrder(TreeNode treeNode) { 31 32 if (treeNode != null) { 33 34 InOrder(treeNode.left); 35 36 if (head == null) { 37 38 head = treeNode; 39 res = treeNode; 40 41 } else { 42 43 head.right=treeNode; 44 treeNode.left=head; 45 head=treeNode; 46 47 48 } 49 InOrder(treeNode.right); 50 } 51 52 } 53 54 }
标签:sub == tle 转换 res 序列 his 中序遍历 node
原文地址:https://www.cnblogs.com/Octopus-22/p/9473656.html