You are viewing a single comment's thread. Return to all comments →
JS solution using reduce. EZ
function missingNumbers(arr, brr) { const groupA = arr.reduce((acc, n) => { acc[n] = (acc[n] || 0) + 1; return acc; }, {}); const groupB = brr.reduce((acc, n) => { acc[n] = (acc[n] || 0) + 1; return acc; }, {}); var missing = []; for(const nu of brr){ if(groupA[nu] !== groupB[nu] && missing.indexOf(nu) < 0){ missing.push(nu); } } return missing.sort(function(a, b) { return a - b; }); }
Seems like cookies are disabled on this browser, please enable them to open this website
Missing Numbers
You are viewing a single comment's thread. Return to all comments →
JS solution using reduce. EZ