Skip to content

Instantly share code, notes, and snippets.

@jsuryahyd
Created October 24, 2020 07:11
Show Gist options
  • Save jsuryahyd/9004cb526051968f0c867d36259d8192 to your computer and use it in GitHub Desktop.
Save jsuryahyd/9004cb526051968f0c867d36259d8192 to your computer and use it in GitHub Desktop.
Algorithm/snippet to get odd item in two arrays
function removal(cA,bA) {
var count = 0;
for (var i = 0; i < cA.length; i++) {
if (i < 0) continue;
for (var j = 0; j < bA.length; j++) {
if (i < 0 || j < 0) continue;
count++;
console.log('comparing', i, j, cA[i], bA[j]);
if (cA[i] == bA[j]) {
console.log('removed', i, j, cA[i], bA[j]);
bA.splice(j, 1);
cA.splice(i, 1);
i = i - 1;
j = j - 1;
}
}
}
console.log(cA, bA);
console.log(count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment