mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
30 lines
1.3 KiB
HTML
30 lines
1.3 KiB
HTML
<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> </p>
|
|
<p><strong>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>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> </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>
|