mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 11:34:46 +08:00
提交242题java解法
This commit is contained in:
@ -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:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user