Skip to content

Commit

Permalink
Merge pull request youngyangyang04#2583 from blueskyson/patch-2
Browse files Browse the repository at this point in the history
Update 0242: Add C solution
  • Loading branch information
youngyangyang04 authored Jun 19, 2024
2 parents 000f0d8 + 0f6ea64 commit 3582a9f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions problems/0242.有效的字母异位词.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,31 @@ object Solution {
}
```

### C

```c
bool isAnagram(char* s, char* t) {
int len1 = strlen(s), len2 = strlen(t);
if (len1 != len2) {
return false;
}

int map1[26] = {0}, map2[26] = {0};
for (int i = 0; i < len1; i++) {
map1[s[i] - 'a'] += 1;
map2[t[i] - 'a'] += 1;
}

for (int i = 0; i < 26; i++) {
if (map1[i] != map2[i]) {
return false;
}
}

return true;
}
```
## 相关题目
* [383.赎金信](https://programmercarl.com/0383.%E8%B5%8E%E9%87%91%E4%BF%A1.html)
Expand Down

0 comments on commit 3582a9f

Please sign in to comment.