• + 0 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;
    }