private static void InOrder(LeetCode897TreeNode root) { if (root == null) { return; } InOrder(root.left); results.Add(root.val); InOrder(root.right); }
public static LeetCode897TreeNode IncreasingBST(LeetCode897TreeNode root) { InOrder(root); var ans = new LeetCode897TreeNode(); var cur = ans; foreach (var item in results) { cur.right = new LeetCode897TreeNode(item); cur = cur.right; } return(ans.right); }
public LeetCode897TreeNode(int val = 0, LeetCode897TreeNode left = null, LeetCode897TreeNode right = null) { this.val = val; this.left = left; this.right = right; }