Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 19, 2016 01:46
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/cdba6a97769db30c2e76 to your computer and use it in GitHub Desktop.
Save jianminchen/cdba6a97769db30c2e76 to your computer and use it in GitHub Desktop.
Two strings - IEnumerable - interesting to read the code
using System;
using System.Collections.Generic;
using System.Linq;
class Solution {
static void Main(String[] args) {
int inputCnt = Convert.ToInt32 (Console.ReadLine ());
if (inputCnt < 1 || inputCnt > 10) return;
string A, B;
IEnumerable<char> res;
bool[] output = new bool[inputCnt];
for (int i = 0; i < inputCnt; i++) {
A = Console.ReadLine ();
B = Console.ReadLine ();
res = A.Intersect (B);
foreach (var elem in res) {
output[i] = true;
break;
}
}
foreach (var elem in output) {
if (elem) Console.WriteLine ("YES");
else Console.WriteLine ("NO");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment