Skip to content

Commit 98adb02

Browse files
authored
feat: add solutions to lc problem: No.0500 (#930)
1 parent 69c2618 commit 98adb02

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

solution/0500-0599/0500.Keyboard Row/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,30 @@ public class Solution {
194194
}
195195
```
196196

197+
### **TypeScript**
198+
199+
```ts
200+
function findWords(words: string[]): string[] {
201+
const s = '12210111011122000010020202';
202+
const ans: string[] = [];
203+
for (const w of words) {
204+
const t = w.toLowerCase();
205+
const x = s[t.charCodeAt(0) - 'a'.charCodeAt(0)];
206+
let ok = true;
207+
for (const c of t) {
208+
if (s[c.charCodeAt(0) - 'a'.charCodeAt(0)] !== x) {
209+
ok = false;
210+
break;
211+
}
212+
}
213+
if (ok) {
214+
ans.push(w);
215+
}
216+
}
217+
return ans;
218+
}
219+
```
220+
197221
### **...**
198222

199223
```

solution/0500-0599/0500.Keyboard Row/README_EN.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,30 @@ public class Solution {
176176
}
177177
```
178178

179+
### **TypeScript**
180+
181+
```ts
182+
function findWords(words: string[]): string[] {
183+
const s = '12210111011122000010020202';
184+
const ans: string[] = [];
185+
for (const w of words) {
186+
const t = w.toLowerCase();
187+
const x = s[t.charCodeAt(0) - 'a'.charCodeAt(0)];
188+
let ok = true;
189+
for (const c of t) {
190+
if (s[c.charCodeAt(0) - 'a'.charCodeAt(0)] !== x) {
191+
ok = false;
192+
break;
193+
}
194+
}
195+
if (ok) {
196+
ans.push(w);
197+
}
198+
}
199+
return ans;
200+
}
201+
```
202+
179203
### **...**
180204

181205
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function findWords(words: string[]): string[] {
2+
const s = '12210111011122000010020202';
3+
const ans: string[] = [];
4+
for (const w of words) {
5+
const t = w.toLowerCase();
6+
const x = s[t.charCodeAt(0) - 'a'.charCodeAt(0)];
7+
let ok = true;
8+
for (const c of t) {
9+
if (s[c.charCodeAt(0) - 'a'.charCodeAt(0)] !== x) {
10+
ok = false;
11+
break;
12+
}
13+
}
14+
if (ok) {
15+
ans.push(w);
16+
}
17+
}
18+
return ans;
19+
}

0 commit comments

Comments
 (0)