diff options
author | Braxton Hall | 2022-10-26 17:26:49 +0000 |
---|---|---|
committer | GitHub | 2022-10-26 17:26:49 +0000 |
commit | 61a4e6758074b4170d702917bce0269fe160ae8a (patch) | |
tree | 5cd8c64b9f63941bd30601363352aed32bcdce47 /entries/kevindhir/aws | |
parent | 01dbd3f3f0829f9bf33bd0c3f152a160218bf09d (diff) | |
parent | 460aaa31a61696c01af80402754c66fb732f7a3b (diff) |
Merge pull request #50 from braxtonhall/kevin
Add Kevin Dhir
Diffstat (limited to 'entries/kevindhir/aws')
-rw-r--r-- | entries/kevindhir/aws/Solution.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/entries/kevindhir/aws/Solution.java b/entries/kevindhir/aws/Solution.java new file mode 100644 index 0000000..602d1b1 --- /dev/null +++ b/entries/kevindhir/aws/Solution.java @@ -0,0 +1,21 @@ +package entries.kevindhir.aws; + +import java.util.Arrays; + +class Solution { + public int fib(int N) { + int[] storage = new int[9999]; + Arrays.fill(storage, -1); + storage[0] = 0; + storage[1] = 1; + return fibMemoized(N, storage); + } + + private int fibMemoized(int N, int[] storage){ + if (storage[N] != -1) return storage[N]; + int calculated = fibMemoized(N-1, storage) + fibMemoized(N-2, storage); + storage[N] = calculated; + return calculated; + } + +}
\ No newline at end of file |