Skip to content

Commit cc6e2bd

Browse files
committed
Fixed sonar
1 parent 3e30f3f commit cc6e2bd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/java/g3401_3500/s3469_find_minimum_cost_to_remove_array_elements/Solution.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ private int solve(int[] nums, int i, int last) {
2323
int res = Math.max(nums[i], nums[i + 1]) + solve(nums, i + 2, last);
2424
res = Math.min(res, Math.max(nums[i], nums[last]) + solve(nums, i + 2, i + 1));
2525
res = Math.min(res, Math.max(nums[i + 1], nums[last]) + solve(nums, i + 2, i));
26-
return dp[i][last] = res;
26+
dp[i][last] = res;
27+
return res;
2728
}
2829
}

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

Lines changed: 6 additions & 6 deletions
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 static final long[][][] DP = new long[105][105][3];
13+
private final long[][][] dp = new long[105][105][3];
1414

1515
// Initialize DP array with -1 (indicating uncomputed states)
16-
static {
17-
for (long[][] longs : DP) {
16+
{
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) {
@@ -46,7 +46,7 @@ private long rec(int o, int e, int req) {
4646
count = multiplyCapped(e, rec(o, e - 1, 0));
4747
}
4848
}
49-
DP[o][e][req] = count;
49+
dp[o][e][req] = count;
5050
return count;
5151
}
5252

0 commit comments

Comments
 (0)