style: enable ConstantName in checkstyle (#5139)

Co-authored-by: Maria Paszkiewicz SCC <maria.paszkiewicz@kit.edu>
This commit is contained in:
marysiuniq
2024-05-02 18:31:37 +02:00
committed by GitHub
parent ede3e4651f
commit 1e2d7e9431
16 changed files with 87 additions and 90 deletions

View File

@@ -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;
}