Created
March 26, 2016 03:22
-
-
Save jianminchen/ff846e884ef9e9e2856a to your computer and use it in GitHub Desktop.
Two string - Java - Scanner, nextInt, next(), toCharArray
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
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int t = sc.nextInt(); | |
while(t-- > 0){ | |
char[] s1 = sc.next().toCharArray(); | |
char[] s2 = sc.next().toCharArray(); | |
int[] chs = new int[1000]; | |
for(int i = 0; i < s1.length; i++){ | |
chs[s1[i]]++; | |
} | |
String result = "NO"; | |
for(int i = 0; i < s2.length; i++){ | |
if(chs[s2[i]]>0){ | |
result = "YES"; | |
break; | |
} | |
} | |
System.out.println(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment