Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
                            
                            
                                分类:
其他好文   时间:
2015-06-14 18:22:19   
                                阅读次数:
105
                             
                         
                    
                        
                            
                            
                                Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
                            
                            
                                分类:
其他好文   时间:
2015-06-14 16:25:49   
                                阅读次数:
101
                             
                         
                    
                        
                            
                            
                                Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by...
                            
                            
                                分类:
其他好文   时间:
2015-06-12 23:57:34   
                                阅读次数:
136
                             
                         
                    
                        
                            
                            
                                Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
                            
                            
                                分类:
其他好文   时间:
2015-06-12 23:40:02   
                                阅读次数:
121
                             
                         
                    
                        
                            
                            
                                将 0 变为 -1 , 则只需找区间和为 0 , 即前缀和相同的最长区间 , 记录一下每个前缀和出现的最早和最晚的位置 , 比较一下就 OK 了------------------------------------------------------------------------------...
                            
                            
                                分类:
其他好文   时间:
2015-06-10 20:57:54   
                                阅读次数:
144
                             
                         
                    
                        
                            
                            
                                超简洁的代码本来考虑是不是真的要每个点求一个maxDepth,看来是的哟public class Solution { public boolean isBalanced(TreeNode root) { if (root==null) return true; i...
                            
                            
                                分类:
其他好文   时间:
2015-06-10 06:35:56   
                                阅读次数:
88
                             
                         
                    
                        
                            
                            
                                Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题解完全抄自ref的说明,感谢!“题解:先复习下什么是二叉搜索树(引自Wikipedia):二叉查找树(B...
                            
                            
                                分类:
其他好文   时间:
2015-06-10 06:33:38   
                                阅读次数:
112
                             
                         
                    
                        
                            
                            
                                平衡二叉树(Self-Balancing Binary Search Tree/Height-Balanced Binary Search Tree),是一种二叉排序树,其中每一个节点的左子树和右子树的高度差至多等于1.平衡二叉树的前提是二叉排序树,不是二叉排序树的都不是平衡二叉树。 
平衡因子BF(Balance Factor):二叉树上节点的左子树深度减去右子树深度的值。最小不平衡子树:距离插入...
                            
                            
                                分类:
其他好文   时间:
2015-06-09 23:48:22   
                                阅读次数:
414
                             
                         
                    
                        
                            
                            
                                DescriptionFarmer John 决定给他的奶牛们照一张合影,他让 N (1 ≤ N ≤ 50,000) 头奶牛站成一条直线,每头牛都有它的坐标(范围: 0..1,000,000,000)和种族(0或1)。 一直以来 Farmer John 总是喜欢做一些非凡的事,当然这次照相也不例外。...
                            
                            
                                分类:
其他好文   时间:
2015-06-09 06:12:07   
                                阅读次数:
239
                             
                         
                    
                        
                            
                            
                                Skip lists are a data structure that can be used in place of balanced trees.Skip lists use probabilistic balancing rather than strictly enforced balan...
                            
                            
                                分类:
其他好文   时间:
2015-06-06 11:58:32   
                                阅读次数:
204