FastPrepCount Elements with at Least One Smaller and One Greater Value

Count Elements with at Least One Smaller and One Greater Value

Uber logoUber● EasyINTERNOA
Learn

Problem statement

You are given an array of integers, count the number of elements having at least one smaller value and at least one greater value.

Input:

The input to the solution function consists of an integer array Nums.

Output:

Return the count.

Function

countElementsWithAtLeastOneSmallerAndOneGreaterValue(nums: int[]) → int

Examples

Example 1

nums = [1, 2, 3]return = 1

Only element 2 satisfies the condition.

Constraints

  • na

More Uber problems

See Uber hiring insights
public int countElementsWithAtLeastOneSmallerAndOneGreaterValue(int[] nums) {
  // write your code here
}
nums[1, 2, 3]
expected1
Checking account…