标签:alt binary nbsp ima xtree info root new image
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { public TreeNode insertIntoMaxTree(TreeNode root, int val) { if(null == root) return new TreeNode(val); if(val > root.val) { TreeNode n = new TreeNode(val); n.left = root; return n; } root.right = insertIntoMaxTree(root.right,val); return root; } }
标签:alt binary nbsp ima xtree info root new image
原文地址:https://www.cnblogs.com/lyr-2000/p/13307511.html