Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 06:22
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/365eb2b69e93573c0b5d to your computer and use it in GitHub Desktop.
Save jianminchen/365eb2b69e93573c0b5d to your computer and use it in GitHub Desktop.
Two string - use string.Contains, 2 dimension array
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