Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 21, 2016 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/10f5cfa5c1ab22070922 to your computer and use it in GitHub Desktop.
Save jianminchen/10f5cfa5c1ab22070922 to your computer and use it in GitHub Desktop.
Two string - JavaScript - string swaps - Julia likes this code
function processData(input) {
//Enter your code here
input=input.split("\n");
var t=input[0];
for(var i=1;i<=((input.length)-2);){
var str1=input[i];
var str2=input[i+1];
var len1=str1.length;
var len2=str2.length;
if(len2<len1)
{
str1=str2;
str2=input[i];
}
for(var j=0;j<str1.length;j++)
{
if(str2.indexOf(str1[j])>=0)
{
console.log("YES");break;
}
}if(j==str1.length){console.log("NO");}
i=i+2;
}
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment