Created
March 19, 2016 06:58
-
-
Save jianminchen/591738de12e21e591634 to your computer and use it in GitHub Desktop.
Two string - using " " to concatenate two input string, and then .Split to separate them.
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 noOfTestCases = Convert.ToInt32(Console.ReadLine()); | |
string[] testCases = new string[noOfTestCases]; | |
for(int i =0; i < noOfTestCases; i++){ | |
testCases[i] = Convert.ToString(Console.ReadLine()) + " " + Convert.ToString(Console.ReadLine()); | |
} | |
for(int ii = 0; ii < noOfTestCases; ii++) { | |
string str1 = testCases[ii].Split(' ')[0]; | |
string str2 = testCases[ii].Split(' ')[1]; | |
bool isTrue = false; | |
for (char ch = 'a'; ch <= 'z'; ch++) { | |
if(str1.Contains(ch.ToString()) && str2.Contains(ch.ToString()) ){ | |
isTrue = true; | |
break; | |
} | |
} | |
if(isTrue){ | |
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