Created
March 19, 2016 05:42
-
-
Save jianminchen/de154d443a1434094260 to your computer and use it in GitHub Desktop.
Two string - using 'z'-'a' in array declaration, use one array size of 26, second one is to use a string.
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) { | |
int lines = Convert.ToInt32(Console.ReadLine()); | |
while(lines-- > 0) | |
{ | |
bool[] founded = new bool['z' - 'a' + 1]; | |
bool found = false; | |
char[] firstWord = Console.ReadLine().ToCharArray(); | |
foreach (char c in firstWord) | |
founded[c - 'a'] = true; | |
char[] secondWord = Console.ReadLine().ToCharArray(); | |
foreach (char c in secondWord) | |
{ | |
if (founded[c - 'a']) | |
{ | |
found = true; | |
break; | |
} | |
} | |
Console.WriteLine(found ? "YES" : "NO"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment