Created
March 19, 2016 01:52
-
-
Save jianminchen/775cf5e16d065e66feae to your computer and use it in GitHub Desktop.
Two strings - Array, BinarySearch method, Array.sort
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
class Solution { | |
static void Main(String[] args) { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ | |
int count = Convert.ToInt32(Console.ReadLine()); | |
for(int i=0; i < count; i++) | |
{ | |
bool found = false; | |
char [] myFirstChar = Console.ReadLine().ToCharArray(); | |
char [] mySecondChar = Console.ReadLine().ToCharArray(); | |
Array.Sort(myFirstChar); | |
Array.Sort(mySecondChar); | |
for(int j=0; j < myFirstChar.Length; j++){ | |
if(Array.BinarySearch(mySecondChar,myFirstChar[j])>=0) | |
{ found = true; break;} | |
} | |
if (found) | |
Console.WriteLine("YES"); | |
else | |
Console.WriteLine("NO"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment