You are viewing a single comment's thread. Return to all comments →
public static String fairRations(List<Integer> B) { List<Integer> ration = new ArrayList<>(B); int count = 0; for(int i=0 ;i< ration.size()-1; i++) { if(ration.get(i) % 2 == 0) continue; if(ration.get(i) % 2 != 0) { ration.set(i, ration.get(i)+1); ration.set(i+1, ration.get(i+1)+1); count += 2; } } if(ration.get(ration.size()-1)%2 != 0) return "NO"; return ""+count; }
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 →