My issue
Can anyone help me in solving this problem?
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0 ; i<n ; i++)
{
String k = sc.next();
String k1 = sc.next();
ArrayList<Character>a1 = new ArrayList<>();
HashSet<Character>h1 = new HashSet<>();
for(int j = 0 ; j<k.length() ; j++)
{
char ch = k.charAt(j);
h1.add(ch);
a1.add(ch);
}
ArrayList<Character>a2 = new ArrayList<>();
HashSet<Character>h2 = new HashSet<>();
for(int k2 = 0 ; k2<k1.length() ; k2++)
{
char ch1 = k1.charAt(k2);
h2.add(ch1);
a2.add(ch1);
}
if((h1.size()==h2.size()) && (a1.size()!=a2.size()))
{
System.out.println("NO");
}
else
{
System.out.println("YES");
}
}
}
}
Problem Link: Granama Recipes Practice Coding Problem - CodeChef