Count Elements With Strictly Smaller and Greater Elements LeetCode solution in Java

1
class Solution {
2
public int countElements(int[] nums) {
3
int nmin = Integer.MAX_VALUE;
4
int nmax = Integer.MIN_VALUE;
5
for (int a : nums) {
6
nmin = Math.min(a, nmin);
7
nmax = Math.max(a, nmax);
8
}
9
int count = 0;
10
for (int a : nums) {
11
if (a > nmin && a < nmax) count++;
12
}
13
return count;
14
}
15
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0