Leetcode 108. Convert Sorted Array to Binary Search Tree
来源:互联网 发布:贪玩蓝月转生数据 编辑:程序博客网 时间:2024/06/07 05:18
public class Solution { public TreeNode sortedArrayToBST(int[] nums) { return helper(0, nums.length-1, nums); } // requires a balanced binary search tree, every time choosing mid of the array as root public static TreeNode helper(int low, int high, int[] nums) { if (low > high) return null; int mid = low + (high-low)/2; TreeNode root = new TreeNode(nums[mid]); root.left = helper(low, mid-1, nums);; root.right = helper(mid+1, high, nums);; return root; }}
0 0
- LeetCode 108. Convert Sorted Array to Binary Search Tree
- [LeetCode]108.Convert Sorted Array to Binary Search Tree
- 108. Convert Sorted Array to Binary Search Tree Leetcode Python
- [Leetcode] 108. Convert Sorted Array to Binary Search Tree
- LeetCode --- 108. Convert Sorted Array to Binary Search Tree
- [leetcode] 108.Convert Sorted Array to Binary Search Tree
- LeetCode 108. Convert Sorted Array to Binary Search Tree
- 108. Convert Sorted Array to Binary Search Tree LeetCode
- [LeetCode]108. Convert Sorted Array to Binary Search Tree
- [LeetCode]108. Convert Sorted Array to Binary Search Tree
- [leetcode] 108. Convert Sorted Array to Binary Search Tree
- Leetcode 108. Convert Sorted Array to Binary Search Tree
- leetCode 108. Convert Sorted Array to Binary Search Tree JAVA
- LeetCode *** 108. Convert Sorted Array to Binary Search Tree
- leetcode 108. Convert Sorted Array to Binary Search Tree
- leetcode 108. Convert Sorted Array to Binary Search Tree
- LeetCode - 108. Convert Sorted Array to Binary Search Tree
- 【LeetCode】108. Convert Sorted Array to Binary Search Tree
- 深入理解PowerManagerService
- Linux内核哈希表分析与应用
- No grammar constraints (DTD or XML schema).....两种解决方法
- jxl操作xls文档小结
- JS中this的四种用法
- Leetcode 108. Convert Sorted Array to Binary Search Tree
- 为什么要使用回调函数?(这个回答太精彩了)
- Java的基本概念-变量与运算
- 如何查看你自己开发的应用的AppleID
- 蓝桥杯——数组、函数问题典例二(2017.1.18)
- SSH三大框架的工作原理及流程
- GET和POST的区别
- android 事件处理机制之requestDisallowInterceptTouchEvent
- better-scroll插件使用