Count Elements With Strictly Smaller and Greater Elements

Easy

Description

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

Examples

Input:nums = [11,7,2,15]
Output:2
Explanation:

7 and 11 satisfy the condition.

Input:nums = [-3,3,3,90]
Output:2
Explanation:

The minimum is -3 and the maximum is 90. The elements 3 and 3 each have both a strictly smaller element (-3) and a strictly greater element (90), so the count is 2.

Input:nums = [5,5,5,5]
Output:0
Explanation:

All elements are equal, so no element has both strictly smaller and strictly greater elements than itself.

Constraints

  • 1 ≤ nums.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!