Created
October 19, 2017 13:42
-
-
Save deque-blog/b1f0a472281d9a2cc8d3033df5852f5c 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
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