You are viewing a single comment's thread. Return to all comments →
a slightly simpler approach
int totalBreads = 0;
for(int i=0;i<B.Length-1;i++){ if(B[i]%2!=0){ B[i]+=1; B[i+1] +=1; totalBreads+=2; } } if(B[B.Length-1]%2!=0){ return -1; } return totalBreads;
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
a slightly simpler approach
int totalBreads = 0;