Sliding Window Maximum

Hard
ArrayQueueSliding WindowHeapAmazonGoogle
Given an array and window size k, print the maximum value in each contiguous window of length k. Input format: - First line: n k - Second line: n integers Print the window maximums on one line.

Constraints

1 <= k <= n <= 10^5
-10^9 <= nums[i] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit