← 返回 oracle 的题目列表Maximum on Both Sides
类型:online_judge
Given an array and a sliding window size k, find the maximum on both sides of each sliding window. Output the maximum values on the left and right sides for each sliding window position.
Input
A one-dimensional integer array.
The sliding window size, k (1 <= k <= array length).
Output
Output the maximum values on the left and right sides as the window slides.
Test Case
Input
[1,3,-1,-3,5,3,6,7]
3
Output
[(1, -3), (3, 5), (5, 6), (6, 7)]
Constraints
Length of array n is between 1 and 10^5.
Example
Input
1,3,-1,-3,5,3,6,7
3