Created
October 24, 2020 07:11
-
-
Save jsuryahyd/9004cb526051968f0c867d36259d8192 to your computer and use it in GitHub Desktop.
Algorithm/snippet to get odd item in two arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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