* fix(guide) add stubs and correct file path misspellings and pr… (#36528) * fix: corrected file path to match curriculum * fix: renamed to newer challenge name * fix: added solutions to articles from challenge files * fix: added missing .english to file name * fix: added missing title to guide article * fix: correct solution for guide article * fix: replaced stub with hint * fix: added space in Hint headers * fix: added solution to guide article * fix: added solution to guide article * test: replaced stub with hint and solution * fix: add Problem number: to title * fix: changed generatorexponential to correct name * fix: renamed knight's tour to knights-tour * fix: updated guide article
613 B
613 B
title
title |
---|
Symmetric difference |
Symmetric difference
Solutions
Solution 1 (Click to Show/Hide)
function symmetricDifference(A, B) {
function relative_complement(A, B) {
return A.filter(function(elem) {
return B.indexOf(elem) == -1
});
}
function unique(ary) {
var u = ary.concat().sort();
for (var i = 1; i < u.length;) {
if (u[i - 1] === u[i])
u.splice(i, 1);
else
i++;
}
return u;
}
return unique(relative_complement(A, B).concat(relative_complement(B, A))).sort();
}