Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes
分类:
其他好文 时间:
2016-02-22 01:34:08
阅读次数:
274
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 想了好久想不出来。后来看了题目分类里面说是DFS,可是没有想出DFS的算法来。后
分类:
其他好文 时间:
2016-02-21 18:32:19
阅读次数:
147
Given a binary tree, return the preorder traversal of its nodes' values. Example Given: 1 / \ 2 3 / \ 4 5 return [1,2,4,5,3]. Challenge Can you do it
分类:
其他好文 时间:
2016-02-21 18:25:22
阅读次数:
153
Description: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program shou
分类:
其他好文 时间:
2016-02-21 14:22:14
阅读次数:
209
Description: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of
分类:
其他好文 时间:
2016-02-21 12:58:13
阅读次数:
189
Given a binary tree, return all root-to-leaf paths. 这道题主要利用一下java的一个特性,String是immutable的对象,不能修改,只能重新生成 /** * Definition of TreeNode: * public class Tr
分类:
其他好文 时间:
2016-02-21 12:57:42
阅读次数:
304
Given a binary tree, return the inorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Challenge Can y
分类:
其他好文 时间:
2016-02-21 11:29:05
阅读次数:
116
原题链接在这里:https://leetcode.com/problems/closest-binary-search-tree-value/ Given a non-empty binary search tree and a target value, find the value in the
分类:
其他好文 时间:
2016-02-21 06:35:58
阅读次数:
181
给定一个升序的单向链表,将它转化为高度平衡的二叉搜索树。...
分类:
其他好文 时间:
2016-02-20 09:19:42
阅读次数:
177
The implementation of binary search is not complicated, but it is a vivid illustration of the power of divide-and-conquer. Here is the code 1 int bina
分类:
其他好文 时间:
2016-02-20 07:03:12
阅读次数:
171