Skip to content

Commit adffcae

Browse files
committed
Fixed sonar
1 parent e7d6029 commit adffcae

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/main/java/g3201_3300/s3273_minimum_amount_of_damage_dealt_to_bob/Solution.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public long minDamage(int pw, int[] damage, int[] health) {
2424
}
2525

2626
private static class Pair implements Comparable<Pair> {
27-
public int key;
28-
public int val;
27+
int key;
28+
int val;
2929

3030
Pair(int key, int val) {
3131
this.key = key;
@@ -34,8 +34,14 @@ private static class Pair implements Comparable<Pair> {
3434

3535
@Override
3636
public boolean equals(Object o) {
37-
Pair p1 = (Pair) o;
38-
return key == p1.key && val == p1.val;
37+
if (this == o) {
38+
return true;
39+
}
40+
if (o == null || getClass() != o.getClass()) {
41+
return false;
42+
}
43+
Pair pair = (Pair) o;
44+
return key == pair.key && val == pair.val;
3945
}
4046

4147
@Override

src/main/java/g3201_3300/s3276_select_cells_in_grid_with_maximum_score/Solution.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public int maxScore(List<List<Integer>> grid) {
2424
boolean[] seen = new boolean[n];
2525
seen[arr[i][1]] = true;
2626
int v = arr[i][0];
27-
for (i++; i < arr.length && arr[i][0] == v; i++) {
27+
i++;
28+
while (i < arr.length && arr[i][0] == v) {
2829
seen[arr[i][1]] = true;
30+
i++;
2931
}
3032
int[] next = Arrays.copyOf(dp, dp.length);
3133
for (int j = 0; j < n; j++) {

src/main/java/g3201_3300/s3277_maximum_xor_score_subarray_queries/Solution.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// #Hard #Array #Dynamic_Programming #2024_09_04_Time_29_ms_(98.87%)_Space_104.3_MB_(65.54%)
44

5+
@SuppressWarnings("java:S3012")
56
public class Solution {
67
public int[] maximumSubarrayXor(int[] nums, int[][] queries) {
78
int n = nums.length;

0 commit comments

Comments
 (0)