Created
March 26, 2016 03:13
-
-
Save jianminchen/6f029bb909ed7d85c012 to your computer and use it in GitHub Desktop.
Two string - Java - thinking in Java
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.util.Scanner; | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
Scanner in = new Scanner(System.in); | |
int N = in.nextInt(); | |
testCase: | |
for(int i = 0; i < N; i++) { | |
String left = in.next(); | |
String right = in.next(); | |
boolean[] leftC = new boolean[26]; | |
for(int j = 0; j < left.length(); j++) { | |
leftC[left.charAt(j) - 'a'] = true; | |
} | |
for(int k = 0; k < right.length(); k++) { | |
if(leftC[right.charAt(k) - 'a']) { | |
System.out.println("YES"); | |
continue testCase; | |
} | |
} | |
System.out.println("NO"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment