Created
March 19, 2016 06:30
-
-
Save jianminchen/1fcc46803321f007eb1b to your computer and use it in GitHub Desktop.
Two String - use StringBuilder for output of console - look into StringBuilder vs string for concatenation
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.Text; | |
class Solution { | |
static void Main(String[] args) { | |
int t = Convert.ToInt32(Console.ReadLine()); | |
StringBuilder sb = new StringBuilder(); | |
for(int i = 0; i < t; i++){ | |
bool[] chars = new bool[26]; | |
string str1 = Console.ReadLine(); | |
foreach(char c in str1.ToCharArray()){ | |
chars[c-'a'] = true; | |
} | |
string str2 = Console.ReadLine(); | |
bool found = false; | |
foreach(char c in str2.ToCharArray()){ | |
if (chars[c-'a']){ | |
sb.AppendLine("YES"); | |
found = true; | |
break; | |
} | |
} | |
if (!found){ | |
sb.AppendLine("NO"); | |
} | |
} | |
Console.WriteLine(sb.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment