Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 21, 2016 18:00
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/c896d4a598b92d127726 to your computer and use it in GitHub Desktop.
Save jianminchen/c896d4a598b92d127726 to your computer and use it in GitHub Desktop.
Two string -
function processData(input) {
var lines = input.split("\n").slice(1), a, b, substring;
for(var i = 0; i < lines.length; i+=2) {
substring = false;
a = lines[i];
b = lines[i+1];
if(b.length > a.length) {
a = lines[i+1];
b = lines[i];
}
for(var j = 0; j < a.length; j++) {
if(b.indexOf(a.charAt(j)) > 0) {
substring = true;
break;
}
}
console.log(substring ? "YES" : "NO");
}
}
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