Created
March 21, 2016 20:03
-
-
Save jianminchen/69119913341c9bea8b0c to your computer and use it in GitHub Desktop.
Two string - JavaScript - Array.ForEach function
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) { | |
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