Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Dec 17, 2023
1 parent cb19a40 commit af46bbf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions coding_interviews/algoexpert/nth-fibonacci/nth-fibonacci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Runtime: O(2^N)
// Space: O(N)

function getNthFib(n) {
if (n === 0) return 0;
if (n === 1) return 0;
if (n === 2) return 1;
return getNthFib(n - 1) + getNthFib(n - 2);
}

0 comments on commit af46bbf

Please sign in to comment.