Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

var test = { f: function(n) { if (n === 0) { return 0; } if (n === 1) { return 1; } else { return f(n - 1) + f(n - 2); } } };

It's fibonacci, we can use dynamic programming to improve the performance, if the f function will be called many many times and n is within a constant range, then use hashmap.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.