Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 05:51
Show Gist options
  • Save jianminchen/6388585c990a42ea76ae to your computer and use it in GitHub Desktop.
Save jianminchen/6388585c990a42ea76ae to your computer and use it in GitHub Desktop.
Two string - using string.Contains function - simple
using System;
using System.Collections.Generic;
using System.IO;
class Solution
{
static void Main(String[] args)
{
//for (int i = 97; i < 123; i++)
// Console.WriteLine((char)i);
//Console.ReadKey();
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
int t = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < t; i++)
{
string a = Console.ReadLine();
string b = Console.ReadLine();
bool printYES = false;
for (int j = 97; j < 123; j++)
if (a.Contains(((char)j).ToString()) && b.Contains(((char)j).ToString()))
{
printYES = true;
break;
}
Console.WriteLine(printYES ? "YES" : "NO");
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment