mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
25 lines
1003 B
HTML
25 lines
1003 B
HTML
<p>给定一个数组 <code>nums</code> 和滑动窗口的大小 <code>k</code>,请找出所有滑动窗口里的最大值。</p>
|
||
|
||
<p><strong>示例:</strong></p>
|
||
|
||
<pre><strong>输入:</strong> <em>nums</em> = <code>[1,3,-1,-3,5,3,6,7]</code>, 和 <em>k</em> = 3
|
||
<strong>输出: </strong><code>[3,3,5,5,6,7]
|
||
<strong>解释:
|
||
</strong></code>
|
||
滑动窗口的位置 最大值
|
||
--------------- -----
|
||
[1 3 -1] -3 5 3 6 7 3
|
||
1 [3 -1 -3] 5 3 6 7 3
|
||
1 3 [-1 -3 5] 3 6 7 5
|
||
1 3 -1 [-3 5 3] 6 7 5
|
||
1 3 -1 -3 [5 3 6] 7 6
|
||
1 3 -1 -3 5 [3 6 7] 7</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<p>你可以假设 <em>k </em>总是有效的,在输入数组不为空的情况下,1 ≤ k ≤ 输入数组的大小。</p>
|
||
|
||
<p>注意:本题与主站 239 题相同:<a href="https://leetcode-cn.com/problems/sliding-window-maximum/">https://leetcode-cn.com/problems/sliding-window-maximum/</a></p>
|