Sliding Window Maximum

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

Code

Algorithms
echo "$arr" | jq --argjson k "$k" '[range(length - $k + 1) as $i | .[$i:$i+$k] | max]'

Parameters

Array of numbers (JSON)

Window size

Server

More Bash Snippets