Convert Sorted Array to Binary Search Tree
来源:互联网 发布:淘宝企业账号怎么注册 编辑:程序博客网 时间:2024/06/13 01:14
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public TreeNode sortedArrayToBST(int[] num) { return arrToBST(num, 0, num.length-1); } public TreeNode arrToBST(int[] num, int l, int r){ if (l>r) return null; TreeNode root = new TreeNode(num[(l+r)/2]); root.left = arrToBST(num, l, (l+r)/2-1); root.right = arrToBST(num, (l+r)/2+1, r); return root; }}
0 0
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- 章鱼哥—VB.NET 控件中你不知道的属性之——AllowDrop 应用详解
- 输入外挂
- C#添加Tao控件来调用opengl
- 章鱼哥—VB.NET RichTextBox.AllowDrop属性的实例
- 二叉树中节点的最大距离(树的最长路径)——递归解法
- Convert Sorted Array to Binary Search Tree
- ggggggggggggggggg
- ggggggggggggggggggggg
- Remove Duplicates from Sorted Array
- Implement strStr()
- 用户体验的一些相关看法
- 网站改版如何处理避免被降权
- 阅读SEO文章 如何分析自身网站数据
- 如何做避免网站优化过度被罚