mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
36
leetcode/problem/sliding-window-maximum.html
Normal file
36
leetcode/problem/sliding-window-maximum.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<p>You are given an array of integers <code>nums</code>, there is a sliding window of size <code>k</code> which is moving from the very left of the array to the very right. You can only see the <code>k</code> numbers in the window. Each time the sliding window moves right by one position.</p>
|
||||
|
||||
<p>Return <em>the max sliding window</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,3,-1,-3,5,3,6,7], k = 3
|
||||
<strong>Output:</strong> [3,3,5,5,6,7]
|
||||
<strong>Explanation:</strong>
|
||||
Window position Max
|
||||
--------------- -----
|
||||
[1 3 -1] -3 5 3 6 7 <strong>3</strong>
|
||||
1 [3 -1 -3] 5 3 6 7 <strong>3</strong>
|
||||
1 3 [-1 -3 5] 3 6 7 <strong> 5</strong>
|
||||
1 3 -1 [-3 5 3] 6 7 <strong>5</strong>
|
||||
1 3 -1 -3 [5 3 6] 7 <strong>6</strong>
|
||||
1 3 -1 -3 5 [3 6 7] <strong>7</strong>
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1], k = 1
|
||||
<strong>Output:</strong> [1]
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code></li>
|
||||
<li><code>1 <= k <= nums.length</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user