Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 06:17
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/7562c5dd310508d48f58 to your computer and use it in GitHub Desktop.
Save jianminchen/7562c5dd310508d48f58 to your computer and use it in GitHub Desktop.
Two string - string.ToCharArray(), Distinct() of Char Array, ToList(), ToArray(), string.IndexOf methods
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
int cases = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < cases; i++){
List<char> one = Console.ReadLine().ToCharArray().Distinct().ToList();
string t = new string(Console.ReadLine().ToCharArray().Distinct().ToArray());
string outPut = "NO";
for(int c = 0; c < one.Count; c++){
if (t.IndexOf(one[c]) >= 0){
outPut = "YES";
break;
}
}
Console.WriteLine(outPut);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment