Merge branch 'master' into master

This commit is contained in:
Carl Sun
2021-05-14 09:12:23 +08:00
committed by GitHub
23 changed files with 464 additions and 128 deletions

View File

@@ -88,19 +88,19 @@ Java
```java
class Solution {
public boolean isAnagram(String s, String t) {
int[] strMap = new int[123];
for (int i = 0; i < s.length(); i++) {
strMap[s.charAt(i) + 0]++;
}
for (int i = 0; i < t.length(); i++) {
strMap[t.charAt(i) + 0]--;
int[] record = new int[26];
for (char c : s.toCharArray()) {
record[c - 'a'] += 1;
}
for (int i = 90; i < 123; i++) {
if (strMap[i] != 0) return false;
for (char c : t.toCharArray()) {
record[c - 'a'] -= 1;
}
for (int i : record) {
if (i != 0) {
return false;
}
}
return true;
}
}