We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Python solution with a stack.
You need to split solution in 2 parts:
Go through the array and add to stack till the next number is smaller than the last value added to stack. When it happens you pop from the stack checking if value is higher than value in max windows array.
You end up with array with maximum windows for some window lengths. You have to populate the missing values with values from the right using a logic that window length for bigger window is also at least maximum for a smaller window.
Min Max Riddle
You are viewing a single comment's thread. Return to all comments →
Python solution with a stack. You need to split solution in 2 parts:
Go through the array and add to stack till the next number is smaller than the last value added to stack. When it happens you pop from the stack checking if value is higher than value in max windows array.
You end up with array with maximum windows for some window lengths. You have to populate the missing values with values from the right using a logic that window length for bigger window is also at least maximum for a smaller window.
`