Created
October 19, 2017 13:43
-
-
Save deque-blog/126ae70e59fa269bafe415884a3f278f to your computer and use it in GitHub Desktop.
This file contains 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
long long bst_count_classic(int n) | |
{ | |
if (n <= 1) return 1; | |
std::vector<long long> memo(n+1, 0); | |
memo[0] = memo[1] = 1; | |
for (int k = 2; k <= n; ++k) | |
for (int i = 0; i < k; ++i) | |
memo[k] += memo[i] * memo[k-i-1]; | |
return memo.back(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment