Created
March 20, 2016 06:18
-
-
Save jianminchen/660a28565839246c2c83 to your computer and use it in GitHub Desktop.
Two string - JavaScript - new style - outer: forEach,
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 lines = input.split("\n"); | |
var count = lines.shift(); | |
outer: | |
while (count--) { | |
var A = lines.shift(); | |
var B = lines.shift(); | |
var letters = {}; | |
A.split("").forEach(function(letter) { if (letter != '\r') letters[letter] = null; }); | |
var Bsplit = B.split(""); | |
for (var letter in Bsplit) { | |
if (letters[Bsplit[letter]] === null) { | |
console.log("YES"); | |
continue outer; | |
} | |
} | |
console.log("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