You are viewing a single comment's thread. Return to all comments →
Hello ayushr2,
I think there is a better solution that runs in O(n) time:
static long minTime(long[] machines, long goal) { double slope = 0; for(long i : machines){//O(N) double temp = (1/(double)i); slope += temp; } double tempSol = goal/slope; if(tempSol/((long)(tempSol)) > 1){//add 1 return (long) tempSol + 1; } return (long) tempSol; }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Time Required
You are viewing a single comment's thread. Return to all comments →
Hello ayushr2,
I think there is a better solution that runs in O(n) time: