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