Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 06:26
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/a91504a793f795886e23 to your computer and use it in GitHub Desktop.
Save jianminchen/a91504a793f795886e23 to your computer and use it in GitHub Desktop.
Two string - Dictionary<char, bool>
using System;
using System.Collections.Generic;
using System.IO;
class Solution
{
static void Main(String[] args)
{
var testCount = Convert.ToInt32(Console.ReadLine());
for (var t = 1; t <= testCount; t++)
{
var a = Console.ReadLine();
var b = Console.ReadLine();
var c = new Dictionary<char, bool>();
foreach (var p in b)
if (!c.ContainsKey(p))
c.Add(p, true);
var noAnswer = true;
foreach (var p in a)
if (c.ContainsKey(p))
{
Console.WriteLine("YES");
noAnswer = false;
break;
}
if (noAnswer)
Console.WriteLine("NO");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment