@@ -0,0 +1,1584 @@
+package com.codeprep.twostrings;%0A%0Aimport java.io.IOException;%0Aimport java.util.HashMap;%0Aimport java.util.Iterator;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0A%0Apublic class Solution %7B%0A%0A    // Complete the twoStrings function below.%0A    static String twoStrings(String s1, String s2) %7B%0A%0A        HashMap%3CString, String%3E s1Vals = cache(s1);%0A        HashMap%3CString, String%3E s2Vals = cache(s2);%0A        return validate(s1Vals, s2Vals);%0A    %7D%0A%0A    static String validate(HashMap%3CString, String%3E s1vals, HashMap%3CString, String%3E s2Vals)%7B%0A%0A        Iterator it = s1vals.entrySet().iterator();%0A        while (it.hasNext()) %7B%0A            Map.Entry pair = (Map.Entry) it.next();%0A            if(s2Vals.get(pair.getKey()) != null)%7B%0A                return %22YES%22;%0A            %7D%0A        %7D%0A        return %22NO%22;%0A    %7D%0A%0A    static HashMap%3CString, String%3E cache(String s)%7B%0A%0A        HashMap%3CString, String%3E cache = new HashMap%3C%3E();%0A        char %5B%5D chars = s.toCharArray();%0A        for(char val: chars)%7B%0A            cache.put(String.valueOf(val), String.valueOf(val));%0A        %7D%0A        return cache;%0A    %7D%0A%0A    private static final Scanner scanner = new Scanner(System.in);%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A%0A        int q = scanner.nextInt();%0A        scanner.skip(%22(%5Cr%5Cn%7C%5B%5Cn%5Cr%5Cu2028%5Cu2029%5Cu0085%5D)?%22);%0A%0A        for (int qItr = 0; qItr %3C q; qItr++) %7B%0A            String s1 = scanner.nextLine();%0A%0A            String s2 = scanner.nextLine();%0A%0A            String result = twoStrings(s1, s2);%0A%0A            System.out.println(result);%0A        %7D%0A        scanner.close();%0A    %7D%0A%7D%0A

solution for two strings problem