We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d41f3ad commit 2b0bf58Copy full SHA for 2b0bf58
src/main/java/g3101_3200/s3115_maximum_prime_difference/Solution.java
@@ -6,25 +6,25 @@ public class Solution {
6
public int maximumPrimeDifference(int[] nums) {
7
int n = nums.length;
8
int i = 0;
9
- while (i < n && !check(nums[i])) {
+ while (i < n && check(nums[i])) {
10
i++;
11
}
12
int j = n - 1;
13
- while (j >= 0 && !check(nums[j])) {
+ while (j >= 0 && check(nums[j])) {
14
j--;
15
16
return j - i;
17
18
19
private boolean check(int n) {
20
if (n < 2) {
21
- return false;
+ return true;
22
23
for (int i = 2; i <= Math.sqrt(n); i++) {
24
if (n % i == 0) {
25
26
27
28
- return true;
+ return false;
29
30
0 commit comments