Posted by: Shere May 2, 2014
Any programmer geeks to help?
Login in to Rate this Post:     0       ?        
I've a solution here. Just a skeleton code for business logic portion not the whole code.
Please advise a condition where and when this won't work. I'll try to modify the code accordingly. But for the scenario dd has posted, this should work like a charm.

int remainingCar = 0
int day = 0;
int i = 0;
for(int car: carArr) {
i++;
totalCarWaitingForRepair = car + remainingCar;
if(totalCarWaitingForRepair >= 8) {
day += totalCarWaitingForRepair/8;
remainingCar = totalCarWaitingForRepair%8;
}
else if (totalCarWaitingForRepair > 0) {
day++;
remainingCar = 0;
}
if(i == carArr.size() && remainingCar > 0) {
day++;
}
}
Read Full Discussion Thread for this article