<p>Given an integer array <code>nums</code>, return <em>the number of elements that have <strong>both</strong> a strictly smaller and a strictly greater element appear in </em><code>nums</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [11,7,2,15]
<strong>Output:</strong> 2
<strong>Explanation:</strong> 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 <code>nums</code>.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [-3,3,3,90]
<strong>Output:</strong> 2
<strong>Explanation:</strong> 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 <code>nums</code>.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 100</code></li>
	<li><code>-10<sup>5</sup> &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

from typing import List

class Solution:
    def countElements(self, nums: List[int]) -> int:
        # Find the minimum and maximum values in the array
        min_val = min(nums)
        max_val = max(nums)
        
        # Initialize a counter for elements that meet the criteria
        count = 0
        
        # Iterate through the array
        for num in nums:
            # Check if the current element is strictly greater than the minimum
            # and strictly less than the maximum
            if min_val < num < max_val:
                count += 1
        
        return count

# Example usage:
solution = Solution()
nums1 = [11, 7, 2, 15]
print(solution.countElements(nums1))  # Output: 2

nums2 = [-3, 3, 3, 90]
print(solution.countElements(nums2))  # Output: 2
41