Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
template<typename Recur>
long long bst_count(Recur recur, int n)
{
if (n <= 1) return 1;
long long sub_counts = 0;
for (int i = 0; i < n; ++i)
sub_counts += recur(i) * recur(n-1-i);
return sub_counts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment