Skip to content

Commit 2b0bf58

Browse files
committed
Fixed style
1 parent d41f3ad commit 2b0bf58

File tree

1 file changed

+5
-5
lines changed
  • src/main/java/g3101_3200/s3115_maximum_prime_difference

1 file changed

+5
-5
lines changed

src/main/java/g3101_3200/s3115_maximum_prime_difference/Solution.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ public class Solution {
66
public int maximumPrimeDifference(int[] nums) {
77
int n = nums.length;
88
int i = 0;
9-
while (i < n && !check(nums[i])) {
9+
while (i < n && check(nums[i])) {
1010
i++;
1111
}
1212
int j = n - 1;
13-
while (j >= 0 && !check(nums[j])) {
13+
while (j >= 0 && check(nums[j])) {
1414
j--;
1515
}
1616
return j - i;
1717
}
1818

1919
private boolean check(int n) {
2020
if (n < 2) {
21-
return false;
21+
return true;
2222
}
2323
for (int i = 2; i <= Math.sqrt(n); i++) {
2424
if (n % i == 0) {
25-
return false;
25+
return true;
2626
}
2727
}
28-
return true;
28+
return false;
2929
}
3030
}

0 commit comments

Comments
 (0)