Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 21, 2016 20:03
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/69119913341c9bea8b0c to your computer and use it in GitHub Desktop.
Save jianminchen/69119913341c9bea8b0c to your computer and use it in GitHub Desktop.
Two string - JavaScript - Array.ForEach function
function processData(input) {
var inp = input.split("\n");
var noOfInputs = inp[0];
function comparator(string1,string2){
for(var i =0; i<string1.length; i++){
if(string2.indexOf(string1[i]) != -1){
return "YES";
}
}
return "NO";
}
inp.forEach(function(d,i){
if ((i!=0) && (i%2 != 0)){
console.log(comparator(inp[i],inp[i+1]));
}
})
//Enter your code here
}
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