You are viewing a single comment's thread. Return to all comments →
my solution in Javascript:
if the count of odd numbers are odd it should return 'NO', and...
function fairRations(B) { let count = 0; if (B.filter((v) => v % 2 == 1).length % 2 == 1) { return "NO"; } else { B.forEach((v, i) => { if (v % 2 == 1) { B[i]++; B[i + 1]++; count += 2; } }); } 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 →
my solution in Javascript:
if the count of odd numbers are odd it should return 'NO', and...