1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-30 12:10:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/长度最小的子数组 [minimum-size-subarray-sum].html

46 lines
1.5 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给定一个含有&nbsp;<code>n</code><strong>&nbsp;</strong>个正整数的数组和一个正整数 <code>target</code><strong></strong></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>找出该数组中满足其总和大于等于<strong> </strong><code>target</code><strong> </strong>的长度最小的 <strong>连续子数组</strong>&nbsp;<code>[nums<sub>l</sub>, nums<sub>l+1</sub>, ..., nums<sub>r-1</sub>, nums<sub>r</sub>]</code> ,并返回其长度<strong></strong>如果不存在符合条件的子数组,返回 <code>0</code></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>target = 7, nums = [2,3,1,2,4,3]
<strong>输出:</strong>2
2023-12-09 18:42:21 +08:00
<strong>解释:</strong>子数组&nbsp;<code>[4,3]</code>&nbsp;是该条件下的长度最小的子数组。
2022-03-27 20:56:26 +08:00
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>target = 4, nums = [1,4,4]
<strong>输出:</strong>1
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>target = 11, nums = [1,1,1,1,1,1,1,1]
<strong>输出:</strong>0
</pre>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li><code>1 &lt;= target &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
2022-03-27 20:56:26 +08:00
</ul>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>进阶:</strong></p>
<ul>
<li>如果你已经实现<em> </em><code>O(n)</code> 时间复杂度的解法, 请尝试设计一个 <code>O(n log(n))</code> 时间复杂度的解法。</li>
</ul>