I was solving an anagram question on geek for geeks but I think the output format is not similar as shown in question over all my code is correct but there is a problem in test cases so see my code and tell me what's wrong in this.
/*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
boolean isAnagram = true;
while (t-- > 0) {
String a = sc.nextLine();
String b = sc.nextLine();
int al[] = new int[256];
for (char c : a.toCharArray()) {
int index = (int) c;
al[index]++;
}
for (char c : b.toCharArray()) {
int index = (int) c;
al[index]--;
}
for (int i = 0; i < 256; i++) {
if (al[i] != 0) {
isAnagram = false;
break;
}
}
if (isAnagram) {
System.out.println("1");
} else {
System.out.println("0");
}
}
}
}
This is the output of custom case: