• + 2 comments

    Thanks for sharing this. Could you please help me in understanding in the below logic. I didnt understand what we are doing here.

    for(int base = 0; base < 3; base++) { int current_sum = 0; for(int i = 0; i < cookies.length; i++) { int delta = cookies[i] - cookies[0] + base; current_sum += (int)delta / 5 + delta % 5 / 2 + delta % 5 % 2 / 1; } sum = Math.min(current_sum,sum); }