https://leetcode-cn.com/problems/valid-anagram/
开始学习Hashmap了,开胃菜,都没用到hashmap,简单的一批。
class Solution {
public boolean isAnagram(String s, String t) {
int[] record = new int[26];
for(char c:s.toCharArray()){
record[c - 'a'] += 1;
}
for(char c:t.toCharArray()){
record[c - 'a'] -= 1;
}
for(int i : record){
if(i != 0){
return false;
}
}
return true;
}
}