Skip to content

Commit 9859a7d

Browse files
committed
"Unique Binary Search Trees": Catalan Number
1 parent fda9495 commit 9859a7d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/96.c

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33

4+
/*
5+
Catalan Number Catalan(n) = 2(2n-1)/(n+1)*Catalan(n-1)
6+
= C(2n, n)/(n+1) = (2n)!/(n+1)!n!
7+
http://mathworld.wolfram.com/CatalanNumber.html
8+
*/
9+
410
int numTrees(int n) {
511
if (n < 3) return n;
612

0 commit comments

Comments
 (0)