Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3...
分类:
其他好文 时间:
2014-09-09 12:31:39
阅读次数:
143
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes...
分类:
其他好文 时间:
2014-09-09 12:14:08
阅读次数:
200
Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes...
分类:
其他好文 时间:
2014-09-09 10:54:08
阅读次数:
190
思路: 其实答案就是 C(m+n-2, m-1). 但是写程序利用动态规划会简单快捷。(给两个代码,第一个方便理解,第二个是基于第一个的优化)
思路:同上,只是最初初始化全 0 . 当前位置为 1 时,则当到达前位置的步数为 0.
分类:
其他好文 时间:
2014-09-09 10:29:48
阅读次数:
255
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique per...
分类:
其他好文 时间:
2014-09-08 00:55:26
阅读次数:
269
public class Solution { public int uniquePaths(int m, int n) { int [][] result = new int[m][n]; for (int i=0; i<m; i++) { ...
分类:
其他好文 时间:
2014-09-07 14:42:25
阅读次数:
181
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of ...
分类:
其他好文 时间:
2014-09-07 14:40:25
阅读次数:
188
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic...
分类:
其他好文 时间:
2014-09-07 12:13:15
阅读次数:
209
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all ...
分类:
其他好文 时间:
2014-09-07 07:38:14
阅读次数:
315
Unique Paths:
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is t...
分类:
其他好文 时间:
2014-09-06 22:37:14
阅读次数:
246