java.lang.Object
g2101_2200.s2148_count_elements_with_strictly_smaller_and_greater_elements.Solution

public class Solution extends Object
2148 - Count Elements With Strictly Smaller and Greater Elements.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [11,7,2,15]</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.</p> <p>Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.</p> <p>In total there are 2 elements having both a strictly smaller and a strictly greater element appear in <code>nums</code>.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [-3,3,3,90]</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.</p> <p>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>.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 100</code></li> <li><code>-10<sup>5</sup> <= nums[i] <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countElements

      public int countElements(int[] nums)