Sherlock and MiniMax Discussions | Algorithms | HackerRank
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.
publicstaticintsherlockAndMinimax(List<Integer>arr,intp,intq){// Write your code hereintl=q-p;long[]M=newlong[l+1];for(intm=0;m<=l;m++){M[m]=Integer.MAX_VALUE;}longMax=Long.MIN_VALUE;longMin=Long.MAX_VALUE;intk=-1;for(inti=p;i<=q;i++){k++;for(Integerj:arr){if(M[k]>Math.abs(j-i)){M[k]=Math.abs(j-i);}}}for(inti=0;i<=l;i++){if(M[i]>Max){Max=M[i];Min=p+i;}}return(int)Min;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and MiniMax
You are viewing a single comment's thread. Return to all comments →
Error: outofmemory.