Last active
March 2, 2017 05:26
-
-
Save Underdoge/1cde9fda80f45a6eff53893836003612 to your computer and use it in GitHub Desktop.
areSimilar
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 areSimilar(A, B) { | |
var different=[]; | |
for (var i=0;i<A.length;i++){ | |
if (A[i]!=B[i]){ | |
different.push(i); | |
} | |
} | |
if(different.length==0) | |
return true; | |
else | |
if (different.length==1||different.length>2){ | |
return false; | |
}else | |
if ((A[different[0]]==B[different[1]])&&(A[different[1]]==B[different[0]])) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment