1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/区间子数组个数 [number-of-subarrays-with-bounded-maximum].html

31 lines
1004 B
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<p>给你一个整数数组 <code>nums</code> 和两个整数:<code>left</code><code>right</code> 。找出 <code>nums</code> 中连续、非空且其中最大元素在范围&nbsp;<code>[left, right]</code> 内的子数组,并返回满足条件的子数组的个数。</p>
<p>生成的测试用例保证结果符合 <strong>32-bit</strong> 整数范围。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [2,1,4,3], left = 2, right = 3
<strong>输出:</strong>3
<strong>解释:</strong>满足条件的三个子数组:[2], [2, 1], [3]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [2,9,2,5,6], left = 2, right = 8
<strong>输出:</strong>7
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= left &lt;= right &lt;= 10<sup>9</sup></code></li>
</ul>