Back to problems

Maximum on Both Sides

Algorithm · Oracle · Medium

Given an integer array and a window length k, determine the maximum values on the left and right sides for every position of the moving window. Input A one-dimensional array of integers. A sliding-window length k (1 <= k <= array length). Output For each window, divide its elements into a left side (the first ceil(k/2) elements) and a right side (the last ceil(k/2) elements); for odd k, the middle element belongs to both sides. Return the maximum value from each side. Test…

Checking your access…