Sliding Window Maximum

Medium
arrays Amazon Google

Given an array of integers and a window size k, find the maximum value in each sliding window of size k.

Example

sliding_max([1, 3, -1, -3, 5, 3, 6, 7], 3)
# => [3, 3, 5, 5, 6, 7]

Test Cases

Python Editor

Output

Click "Run" to see results...