Count Elements With Strictly Smaller and Greater Elements

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

Example 1
Inputnums = [11,7,2,15]
Output2
The elements 7 and 11 each have both a strictly smaller and a strictly greater element in nums, so the total is 2.
Example 2
Inputnums = [-3,3,3,90]
Output2
Each of the two elements with value 3 has -3 strictly smaller and 90 strictly greater, so the total is 2.

Constraints

  • 1 <= nums.length <= 100
  • -10^5 <= nums[i] <= 10^5

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate