Created
March 19, 2016 01:58
Revisions
-
jianminchen created this gist
Mar 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int T = int.Parse(Console.ReadLine()); for(int i=0; i<T; i++){ String A = Console.ReadLine(); String B = Console.ReadLine(); Boolean flag = false; char [] a = A.ToCharArray(); Array.Sort(a); char [] b = B.ToCharArray(); Array.Sort(b); int j=0,k=0; while(j<a.Length && k<b.Length){ if(a[j]==b[k]){ flag = true; break; } else if(a[j]<b[k]) j++; else k++; } if(flag) Console.WriteLine("YES"); else Console.WriteLine("NO"); } } }