Sliding Window Maximum

Find the maximum value in each sliding window of size k as it moves across the array.

Code

Algorithms
[max(arr[i:i+k]) for i in range(len(arr) - k + 1)]

Parameters

Array of numbers

Window size

Server

More Python Snippets