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.
publicstaticintequal(List<Integer>arr){// Store all the possibilitiesint[]possibilities=newint[5];// Start with the minimum elementintminimum=Collections.min(arr);for(inti=0;i<possibilities.length;i++){for(intk:arr){intdiff=k-minimum;intstepsRequired=diff/5+(diff%5)/2+((diff%5)%2)/1;possibilities[i]+=stepsRequired;}minimum--;}// Return the minimum number out of all the possibilitiesreturnArrays.stream(possibilities).min().getAsInt();}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →