class Solution {
public boolean isAnagram(String s, String t) {
HashMap<Character,Integer> map = new HashMap<>();
if(s.equals(t)||s.length()!=t.length()){
return false;
}
int[] arr =new int[32];
for (int i = 0; i < s.length(); i++) {
arr[s.charAt(i)-'a']+=1;
}
for (int j = 0; j < t.length(); j++) {
arr[t.charAt(j)-'a']-=1;
if(arr[t.charAt(j)-'a']<0){
return false;
}
}
return true;
}
}
class Solution {
public boolean isAnagram(String s, String t) {
if (s.length() != t.length() || s.equals(t)) {
return false;
}
char[] str1 = s.toCharArray();
char[] str2 = t.toCharArray();
Arrays.sort(str1);
Arrays.sort(str2);
return Arrays.equals(str1, str2);
}
}