Created
March 21, 2016 18:50
-
-
Save jianminchen/10f5cfa5c1ab22070922 to your computer and use it in GitHub Desktop.
Two string - JavaScript - string swaps - Julia likes this code
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 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