← Back to all problems
Hard

Sliding Window Maximum

Updated Feb 24, 2026

Problem

Return max value in each sliding window of size k.

Constraints

1 <= nums.length <= 10^5

Examples

Example 1

Input: {"nums": [1, 3, -1, -3, 5, 3, 6, 7], "k": 3}
Output: [3, 3, 5, 5, 6, 7]

Function Signature

def maxSlidingWindow(self, nums: list[int], k: int) -> list[int]

How to Submit

Implement a Solution class with a maxSlidingWindow method.

Your method will be called with the input parameters and should return the answer.