Created
June 9, 2011 03:17
-
-
Save arcthur/1015974 to your computer and use it in GitHub Desktop.
complementary
This file contains hidden or 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 complementary(aArr, bArr) { | |
if (bArr.length === 0) { | |
return aArr; | |
} | |
var str = bArr.join(','), | |
_a = aArr.concat(bArr).sort(); | |
_a.sort(function (a, b) { | |
if (a === b) { | |
var n = str.indexOf(a), | |
m = aArr.indexOf(a); | |
if (n != -1) { | |
aArr.splice(m, 1); | |
} | |
} | |
}); | |
return aArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment