File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
solution/0500-0599/0500.Keyboard Row Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,30 @@ public class Solution {
194
194
}
195
195
```
196
196
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
+
197
221
### ** ...**
198
222
199
223
```
Original file line number Diff line number Diff line change @@ -176,6 +176,30 @@ public class Solution {
176
176
}
177
177
```
178
178
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
+
179
203
### ** ...**
180
204
181
205
```
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments