Sliding Window Maximum

You are given an array of integers and a sliding window of a specified size. The window moves from the left of the array to the right, and you can only see the numbers within the window at each step. Your task is to return the maximum value from the sliding window.

Constraints

  • 1 <= nums.length <= 10^5
  • -10^4 <= nums[i] <= 10^4
  • 1 <= k <= nums.length
Saving… · 2 lines
class Solution:
def slidingWindowMaximum(self, nums: List[int], k: int) -> List[int]:
Console

Click Run to execute sample tests.