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