提交242题java解法
This commit is contained in:
parent
47d2496189
commit
f1fa019b4a
|
|
@ -85,7 +85,24 @@ public:
|
||||||
|
|
||||||
|
|
||||||
Java:
|
Java:
|
||||||
|
```java
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
Python:
|
Python:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue