题目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikip ...
分类:
其他好文 时间:
2016-07-05 07:40:26
阅读次数:
155
一天一道LeetCode
本系列文章已全部上传至我的github,地址:ZeeCoder‘s Github
欢迎大家关注我的新浪微博,我的新浪微博
欢迎转载,转载请注明出处
(一)题目
Given an array where elements are sorted in ascending order, convert it to a height balanced BST....
分类:
其他好文 时间:
2016-07-03 20:01:56
阅读次数:
200
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Example 2 1->2->3 => / \ 1 3 分析:非常简单,用递归 ...
分类:
其他好文 时间:
2016-07-03 07:03:00
阅读次数:
113
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
其他好文 时间:
2016-06-28 18:21:40
阅读次数:
148
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 升序数组a[],构造平衡二叉树,左右子树高度差不超过1. 思路: 利用先序构建二叉树的方法,将数组的中间 ...
分类:
其他好文 时间:
2016-06-26 22:33:47
阅读次数:
186
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note:A solution using O(n) space i ...
分类:
其他好文 时间:
2016-06-26 22:33:43
阅读次数:
140
一天一道LeetCode
本系列文章已全部上传至我的github,地址:ZeeCoder‘s Github
欢迎大家关注我的新浪微博,我的新浪微博
欢迎转载,转载请注明出处
(一)题目
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is def...
分类:
其他好文 时间:
2016-06-24 15:39:57
阅读次数:
147
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题目:将升序的链表,转化为BST(note:此BST要求是高度平衡,就是树种左右 ...
分类:
其他好文 时间:
2016-06-22 15:48:46
阅读次数:
119