Scanner s = new Scanner(System.in);
char[] ch = s.next().toCharArray();
Arrays.sort(ch);
StringBuilder sb = new StringBuilder();
sb.append(ch);
int n = s.nextInt();
while (n-- > 0) {
char[] book = s.next().toCharArray();
Arrays.sort(book);
StringBuilder sb2 = new StringBuilder();
sb2.append(book);
System.out.println(sb.equals(sb2));
}
it returns false.
input
act
1
cat
output
false
i tried to check two string are same or not without working with array but input will be in array.