static long long lazy_map(std::unordered_map<int, long long>& memo, int n) | |
{ | |
auto& computed = memo[n]; | |
if (computed) return computed; | |
auto recur = [&](int k) { return lazy_map(memo, k); }; | |
return computed = bst_count(recur, n); | |
} | |
long long bst_count_map(int n) | |
{ | |
std::unordered_map<int, long long> memo; | |
return lazy_map(memo, n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment