leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2623.js (304B)


0 /**
1 * @param {Function} fn
2 */
4 function memoize(fn) {
5 const cache = {};
6 return function(...args) {
7 const key = JSON.stringify(args);
8 if (key in cache) {
9 return cache[key];
10 }
11 const functionOutput = fn(...args);
12 cache[key] = functionOutput;
13 return functionOutput;
14 }
15 }