// FindNumberOfBSTFromN.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <vector>
#include <iostream>
using namespace std;
int F(int);
int f(int, int);
int f(int i, int N)
{
if (i == 1 || i == N)
{
return F(N-1);
}
return F(i-1)*F(N-i);
}
int F(int N)
{
if (N < 1)
{
return 0;
}
if (N == 1)
{
return 1;
}
if (N == 2)
{
return 2;
}
int sum = 0;
for (int i = 1; i <=N; i++)
{
sum += f(i, N);
}
return sum;
}
int _tmain(int argc, _TCHAR* argv[])
{
int Num = F(5);
printf("%d\r\n", Num);
return 0;
}
LeetCode Unique Binary Search Trees
最新推荐文章于 2021-09-15 15:18:50 发布