You are viewing a single comment's thread. Return to all comments →
def solve(arr, queries): mins = [] for k in queries: current_window = deque() maxs = [] for i in range(len(arr)): if current_window and current_window[0] < i - k + 1: current_window.popleft() while current_window and arr[current_window[-1]] < arr[i]: current_window.pop() current_window.append(i) if i >= k -1: maxs.append(arr[current_window[0]]) mins.append(min(maxs)) return mins
Seems like cookies are disabled on this browser, please enable them to open this website
Queries with Fixed Length
You are viewing a single comment's thread. Return to all comments →