mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
style: enable ConstantName in checkstyle (#5139)
Co-authored-by: Maria Paszkiewicz SCC <maria.paszkiewicz@kit.edu>
This commit is contained in:
@@ -9,7 +9,7 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class Fibonacci {
|
||||
|
||||
private static final Map<Integer, Integer> map = new HashMap<>();
|
||||
private static final Map<Integer, Integer> CACHE = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Methods all returning [0, 1, 1, 2, 3, 5, ...] for n = [0, 1, 2, 3, 4, 5, ...]
|
||||
@@ -30,8 +30,8 @@ public class Fibonacci {
|
||||
* Outputs the nth fibonacci number
|
||||
*/
|
||||
public static int fibMemo(int n) {
|
||||
if (map.containsKey(n)) {
|
||||
return map.get(n);
|
||||
if (CACHE.containsKey(n)) {
|
||||
return CACHE.get(n);
|
||||
}
|
||||
|
||||
int f;
|
||||
@@ -40,7 +40,7 @@ public class Fibonacci {
|
||||
f = n;
|
||||
} else {
|
||||
f = fibMemo(n - 1) + fibMemo(n - 2);
|
||||
map.put(n, f);
|
||||
CACHE.put(n, f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user