Created
March 19, 2016 06:17
-
-
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
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 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