We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4a3ea4c + 21fc5cd commit 92c507bCopy full SHA for 92c507b
problems/0242.有效的字母异位词.md
@@ -214,7 +214,23 @@ var isAnagram = function(s, t) {
214
};
215
```
216
217
+TypeScript:
218
+
219
+```typescript
220
+function isAnagram(s: string, t: string): boolean {
221
+ if (s.length !== t.length) return false;
222
+ let helperArr: number[] = new Array(26).fill(0);
223
+ let pivot: number = 'a'.charCodeAt(0);
224
+ for (let i = 0, length = s.length; i < length; i++) {
225
+ helperArr[s.charCodeAt(i) - pivot]++;
226
+ helperArr[t.charCodeAt(i) - pivot]--;
227
+ }
228
+ return helperArr.every(i => i === 0);
229
+};
230
+```
231
232
Swift:
233
234
```Swift
235
func isAnagram(_ s: String, _ t: String) -> Bool {
236
if s.count != t.count {
0 commit comments