## GZY的博客

There is no failure, only feedback

# leetcode：96. Unique Binary Search Trees

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 5 unique BST's.

   1         3     3      2      1
\       /     /      / \      \
3     2     1      1   3      2
/     /       \                 \
2     1         2                 3


/**
* @param {number} n
* @return {number}
*/
var numTrees = function(n) {
var map = [1,1];
for(var i = 2; i <= n; i++) {
map[i] = 0;
for(var j = 1; j <= i; j++) {
map[i] += (map[j-1] * map[i-j])
}
}
return map[n];
};

#### LeetCode96:Unique Binary Search Trees

2015-06-24 15:56:10

#### LeetCode 96 — Unique Binary Search Trees（C++ Java Python）

2014-04-01 21:07:32

#### leetcode-java-96. Unique Binary Search Trees

2016-06-30 10:08:42

#### LeetCode || Unique Binary Search Trees

2014-04-09 23:16:41

#### LeetCode 96:Unique Binary Search Trees

2015-12-31 16:35:13

#### 96 Unique Binary Search Trees

2015-11-25 21:04:50

#### LeetCode | Unique Binary Search Trees II

2013-12-23 14:58:40

#### Unique Binary Search Trees -- LeetCode

2014-04-30 06:16:29

#### LeetCode(95)Unique Binary Search Trees II

2014-01-13 05:20:18

#### leetcode 95. Unique Binary Search Trees II | Java最短代码实现

2016-03-09 20:43:19