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 that passes all test cases. I am only looking for the bounds of each subquery so I'm saving a lot of time.
defsolve(arr,queries):n=len(arr)minimums=[]fordinqueries:maximum=minimum=max(arr[0:d])foriinrange(1,n-d+1):# New upper bound is higherifarr[i+d-1]>maximum:maximum=arr[i+d-1]# Previous lower bound was the maximumelifarr[i-1]==maximum:maximum=max(arr[i:i+d])# Else, we mantain the current maximum# We update the minimumifmaximum<minimum:minimum=maximumminimums.append(minimum)returnminimums
Cookie support is required to access HackerRank
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 →
Python solution that passes all test cases. I am only looking for the bounds of each subquery so I'm saving a lot of time.