Created
March 20, 2016 05:32
-
-
Save jianminchen/12a0caba6512b206e276 to your computer and use it in GitHub Desktop.
Two string - JavaScript solution - split, shift, splice(0,2), stdin.resume, setEncoding
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 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