Skip to content

Commit bcfdd99

Browse files
committed
Fixed sonar
1 parent 8274c73 commit bcfdd99

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/g3401_3500/s3470_permutations_iv/Solution.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public class Solution {
1010
// Define a large constant value to cap calculations and prevent overflow
1111
private static final long CAP = 1000000000000001L;
1212
// 3D DP array to store precomputed results for dynamic programming
13-
private final long[][][] dp = new long[105][105][3];
13+
private static final long[][][] DP = new long[105][105][3];
1414

1515
// Initialize DP array with -1 (indicating uncomputed states)
16-
{
17-
for (long[][] longs : dp) {
16+
static {
17+
for (long[][] longs : DP) {
1818
for (long[] aLong : longs) {
1919
Arrays.fill(aLong, -1);
2020
}
@@ -26,8 +26,8 @@ private long rec(int o, int e, int req) {
2626
if (o == 0 && e == 0) {
2727
return 1;
2828
}
29-
if (dp[o][e][req] != -1) {
30-
return dp[o][e][req];
29+
if (DP[o][e][req] != -1) {
30+
return DP[o][e][req];
3131
}
3232
long count = 0;
3333
if (req == 2) {
@@ -42,7 +42,7 @@ private long rec(int o, int e, int req) {
4242
} else {
4343
if (e > 0) count = multiplyCapped(e, rec(o, e - 1, 0));
4444
}
45-
dp[o][e][req] = count;
45+
DP[o][e][req] = count;
4646
return count;
4747
}
4848

0 commit comments

Comments
 (0)