Skip to content

Commit fc04e9e

Browse files
committed
添加242.有效的字母异位词JavaScript版本
1 parent 57d80b6 commit fc04e9e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

problems/0242.有效的字母异位词.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ func isAnagram(s string, t string) bool {
140140
}
141141
```
142142

143+
javaScript:
144+
145+
```js
146+
var isAnagram = function(s, t) {
147+
const resSet = new Array(25).fill(0);
148+
const base = "a".charCodeAt();
149+
for(const i of s) {
150+
resSet[i.charCodeAt() - base]++;
151+
}
152+
for(const i of t) {
153+
resSet[i.charCodeAt() - base]--;
154+
// if(val < 0) return false;
155+
}
156+
return resSet.every(i => !i);
157+
};
158+
```
159+
143160
## 相关题目
144161

145162
* 383.赎金信

0 commit comments

Comments
 (0)