Created
November 28, 2014 00:46
-
-
Save fjc-oai/5f03366c1e4ac9ac13ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int numTrees(int n) { | |
vector<int>f(n+1,0); | |
f[0]=1; | |
for(int i=1;i<=n;i++){ | |
for(int j=0;j<=i-1;j++) | |
f[i]+=f[j]*f[i-1-j]; | |
} | |
return f[n]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment