You are viewing a single comment's thread. Return to all comments →
Here's my JS approach:
let oddIDs = []; for(let i = 0; i < B.length; i++){ if(B[i]%2 !== 0){ oddIDs.push(i); } } if(oddIDs.length%2 !== 0) { return `NO`; } else{ let count = 0; for(let i = 0; i < oddIDs.length; i++){ count += Math.abs(oddIDs[i] - oddIDs[i+1]) * 2; i++; } 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 →
Here's my JS approach: