Created
March 19, 2016 06:22
-
-
Save jianminchen/365eb2b69e93573c0b5d to your computer and use it in GitHub Desktop.
Two string - use string.Contains, 2 dimension array
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; | |
using System.Linq; | |
class Solution { | |
static void Main(String[] args) { | |
int caseCount = Convert.ToInt32(Console.ReadLine()); | |
string[,] caseList = new string[caseCount, 2]; | |
for (int i = 0; i < caseCount; i++) | |
{ | |
caseList[i, 0] = new string(Console.ReadLine().Distinct().ToArray()); | |
caseList[i, 1] = new string(Console.ReadLine().Distinct().ToArray()); | |
} | |
for (int i = 0; i < caseCount; i++) | |
{ | |
string result = "NO"; | |
foreach (char charect in caseList[i, 0]) | |
{ | |
if(caseList[i, 1].Contains(charect )) | |
{ | |
result = "YES"; | |
break; | |
} | |
} | |
Console.WriteLine(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment