#Leet Code# Convert Sorted Array to Binary Search Tree
描述:递归
代码:
class Solution:
# @param num, a list of integers
# @return a tree node
def sortedArrayToBST(self, num):
if len(num) == 0:
return None mid_index = len(num) / 2 tmp_tree = TreeNode(num[mid_index])
tmp_tree.left = self.sortedArrayToBST(num[:mid_index])
tmp_tree.right = self.sortedArrayToBST(num[mid_index + 1:]) return tmp_tree
#Leet Code# Convert Sorted Array to Binary Search Tree的更多相关文章
- [Leetcode][JAVA] Convert Sorted Array to Binary Search Tree &&  Convert Sorted List to Binary Search Tree
		
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending ord ...
 - 【leetcode】Convert Sorted Array to Binary Search Tree
		
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending ord ...
 - 【LeetCode OJ】Convert Sorted Array to Binary Search Tree
		
Problem Link: http://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ Same idea ...
 - 34. Convert Sorted List to Binary Search Tree  &&  Convert Sorted Array to Binary Search Tree
		
Convert Sorted List to Binary Search Tree OJ: https://oj.leetcode.com/problems/convert-sorted-list-t ...
 - LeetCode:Convert Sorted Array to Binary Search Tree,Convert Sorted List to Binary Search Tree
		
LeetCode:Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in asce ...
 - Convert Sorted Array to Binary Search Tree
		
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending ord ...
 - 37. leetcode 108. Convert Sorted Array to Binary Search Tree
		
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 描述 Given an array where elements are sorted in ascen ...
 - LeetCode: Convert Sorted Array to Binary Search Tree  解题报告
		
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending ord ...
 
随机推荐
- Cocos2d-x 2.0 自适应多种分辨率
			
转自:http://dualface.github.io/blog/2012/08/17/cocos2d-x-2-dot-0-multi-resolution/ cocos2d-x 2.0 提供一个极 ...
 - MySQL启动和关闭服务命令
			
MySQL启动和关闭服务命令 1.启动服务命令 net start mysql 2.关闭服务命令 net stop mysql
 - Sublime 格式化代码 快捷键以及插件使用
			
来自Vic___:http://blog.csdn.net/vic___ 其实在sublime中已经自建了格式化按钮: Edit -> Line -> Reindent 只是sub ...
 - 从零开始,打造自己的首个 iOS 框架
			
如果你曾试图创建自己的iOS框架,你知道这不是一个头脑发热作出的决定 — 管理依赖以及写测试用例一点也不简单.本教程将会带你从头到尾创建你的第一个iOS框架,让你可以创建自己的框架. 我们将在框架暴露 ...
 - iOS 推送,当接到推送消息时如何处理?
			
接收到通知时有两种进入的方式:1.当app未运行时(BOOL)application:(UIApplication *)application didFinishLaunchingWithOption ...
 - Pyhon之类学习1
			
#!/usr/bin/python # Filename: class.py __metaclass__=type class Person: def set_name(self,name): sel ...
 - Java开发十大常用网站
			
Stackoverflow:有成千上万个好问题和答案 DZone:有相当多的开发者在这个网站上分享他们博客文章 LeetCode:如果有Java方面的面试问题可在教程中找到答案 Java SE技术文档 ...
 - 在Vivado中调用ModelSim生成FSM的状态转移图
			
如果我们已经书写了一段FSM代码,现在想倒过来把它转换成为状态转移图,方便我们直观地检查我们书写的状态对不对(在写论文什么的画图太麻烦的时候,有个自动生成的是多方便啊!),应该怎么弄呢?通过在Viva ...
 - 20151221jqueryUI---日历UI代码备份
			
$(function () { $('#search_button').button({ icons : { primary : 'ui-icon-search', }, }); $('#reg'). ...
 - java log日志的输出。
			
在Spring框架中添加日志功能: pom.xml <dependency> <groupId>log4j</groupId> <artifactId> ...