Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 20, 2016 05:32
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/12a0caba6512b206e276 to your computer and use it in GitHub Desktop.
Save jianminchen/12a0caba6512b206e276 to your computer and use it in GitHub Desktop.
Two string - JavaScript solution - split, shift, splice(0,2), stdin.resume, setEncoding
function check(arr) {
a = arr[0];
b = arr[1];
var contains = 'NO';
for (var i=0;i<b.length;i++) {
if (a.indexOf(b[i]) != -1) {
contains = 'YES';
break;
}
}
console.log(contains)
}
function processData(input) {
//Enter your code here
var input = input.split("\n");
input.shift();
while (input.length) {
check(input.splice(0,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