Skip to content

Instantly share code, notes, and snippets.

@Cee
Created May 29, 2014 00:52
Show Gist options
  • Save Cee/6345fdfe42312ad318b1 to your computer and use it in GitHub Desktop.
Save Cee/6345fdfe42312ad318b1 to your computer and use it in GitHub Desktop.
public class Solution {
public int numTrees(int n) {
if (n == 0) return 1;
if (n == 1) return 1;
if (n == 2) return 2;
int ret = 0;
for (int i = 1; i <= n; i++){
ret = ret + numTrees(i - 1) * numTrees(n - i);
}
return ret;
}
}
@Cee
Copy link
Author

Cee commented May 29, 2014

回归BST定义w

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment