I gave an array Aof n integers and a Qrequest in the form X Dfor each request I have to find the maximum element in the basement[Ax , A(x-D),A(x-2D)..]
For instance:
A = [1,2,3,4,5,6,17,8]
we have query 7 2
Sub Array [17,5,3,1] Ans=17
How can we solve this with time complexity better than O(Q*N), since no index is updated, can it be deleted offline using any technique
I do not think it Square Decompositionwill work here.
source
share