Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/591738de12e21e591634 to your computer and use it in GitHub Desktop.
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.
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