Created
March 21, 2016 19:21
-
-
Save jianminchen/8dca6d1fd8fe96b7323c to your computer and use it in GitHub Desktop.
Two String - JavaScript - using jagged array - good practice to follow
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) { | |
input = input.split('\n'); | |
for(var i=1;i<input.length;i+=2){ | |
var table = {}; | |
for(var j=0;j<input[i].length;j++){ | |
table[input[i][j]] = true; | |
} | |
for(var k=0;k<input[i+1].length;k++){ | |
if(table[input[i+1][k]]){ | |
console.log("YES"); | |
break; | |
} | |
if(k === input[i+1].length -1){ | |
console.log("NO"); | |
break; | |
} | |
} | |
} | |
} | |
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