forked from aditiraj/hackerrankSolutions-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwoStrings.js
More file actions
26 lines (22 loc) · 679 Bytes
/
twoStrings.js
File metadata and controls
26 lines (22 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function twoStrings(s1, s2){
// If both the strings have any lowercase alphabet in common then return yes.
var ar1= s1.split("");
var ar2= s2.split("");
var string="abcdefghijklmnopqrstuvwxyz";
var alphabets= string.split("");
for(var i=0; i<alphabets.length; i++){
if(ar1.indexOf(alphabets[i])>=0 && ar2.indexOf(alphabets[i])>=0){
return "YES";
}
}
return "NO";
}
function main() {
var q = parseInt(readLine());
for(var a0 = 0; a0 < q; a0++){
var s1 = readLine();
var s2 = readLine();
var result = twoStrings(s1, s2);
process.stdout.write("" + result + "\n");
}
}