Count Elements With Strictly Smaller and Greater Elements
The problem asks us to find the number of elements in the given array that have both a strictly smaller and a strictly greater element within the array.
We’ll iterate through the array and for each element, we’ll check if there’s a strictly smaller and a strictly greater element in the array.
Here’s the code:


Explanation
 For each element
num
in the array, we’re using theany
function along with a generator expression to check if there’s a strictly smaller and a strictly greater element in the array.  If both conditions are met, we increment the count.
 We return the final count as the result.
Example
For the input nums = [11,7,2,15]
, the method would return 2
, since the elements 7
and 11
have both strictly smaller and strictly greater elements within the array.