Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.

&nbsp;
Example 1:

Input: nums = [11,7,2,15]
Output: 2
Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
In total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.


Example 2:

Input: nums = [-3,3,3,90]
Output: 2
Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 100
	-105 &lt;= nums[i] &lt;= 105


class Solution:
    def countElements(self, nums: List[int]) -> int:
        M = max(nums)
        m = min(nums)
        return sum(1 for i in nums if m<i<M)
class Solution {
    public int countElements(int[] nums) {
        int nmin=Integer.MAX_VALUE;
        int nmax=Integer.MIN_VALUE;
        for(int a:nums)
        {
            nmin=Math.min(a,nmin);
            nmax=Math.max(a,nmax);
        }
        int count=0;
        for(int a:nums)
        {
            if(a>nmin && a<nmax)
                count++;
        }
        return count;
    }
}
class Solution {
public:
    int countElements(vector<int>& nums) {
        int M = *max_element(nums.begin(), nums.end()); 
        int m = *min_element(nums.begin(), nums.end()); 
        int res = 0;
        for(int i = 0; i < nums.size(); i++){
            if(nums[i] > m && nums[i] < M) res++;
        }
        return res;
    }
};
var countElements = function(nums) {
    let map = {}, total = 0;

    // adding elements to map
    for(let i of nums) map[i] ? map[i]++ : map[i] = 1;

    // Removing repeated elements
    let newNums = [... new Set(nums)];

    // If length of array after removing repeated nums is less than three return 0;
    if(newNums.length < 3) return 0;

    // sort the newNums array and remove the first and last element.
    // for all the remaining elements check their number in map and add it to total variable
    newNums.sort((a,b) => a-b).slice(1, newNums.length-1).forEach(num => total += map[num]);

    // return total variable
    return total;
};
Count Elements With Strictly Smaller and Greater Elements