File tree 3 files changed +16
-16
lines changed
solution/1400-1499/1451.Rearrange Words in a Sentence
3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -166,11 +166,11 @@ class Solution {
166
166
167
167
``` ts
168
168
function arrangeWords(text : string ): string {
169
- let words: string [] = text .split (" " );
170
- words [0 ] = words [0 ].toLowerCase ();
171
- words .sort ((a , b ) => a .length - b .length );
172
- words [0 ] = words [0 ].charAt (0 ).toUpperCase () + words [0 ].slice (1 );
173
- return words .join (" " );
169
+ let words: string [] = text .split (' ' );
170
+ words [0 ] = words [0 ].toLowerCase ();
171
+ words .sort ((a , b ) => a .length - b .length );
172
+ words [0 ] = words [0 ].charAt (0 ).toUpperCase () + words [0 ].slice (1 );
173
+ return words .join (' ' );
174
174
}
175
175
```
176
176
Original file line number Diff line number Diff line change @@ -151,11 +151,11 @@ class Solution {
151
151
152
152
``` ts
153
153
function arrangeWords(text : string ): string {
154
- let words: string [] = text .split (" " );
155
- words [0 ] = words [0 ].toLowerCase ();
156
- words .sort ((a , b ) => a .length - b .length );
157
- words [0 ] = words [0 ].charAt (0 ).toUpperCase () + words [0 ].slice (1 );
158
- return words .join (" " );
154
+ let words: string [] = text .split (' ' );
155
+ words [0 ] = words [0 ].toLowerCase ();
156
+ words .sort ((a , b ) => a .length - b .length );
157
+ words [0 ] = words [0 ].charAt (0 ).toUpperCase () + words [0 ].slice (1 );
158
+ return words .join (' ' );
159
159
}
160
160
```
161
161
Original file line number Diff line number Diff line change 1
1
function arrangeWords ( text : string ) : string {
2
- let words : string [ ] = text . split ( " " ) ;
3
- words [ 0 ] = words [ 0 ] . toLowerCase ( ) ;
4
- words . sort ( ( a , b ) => a . length - b . length ) ;
5
- words [ 0 ] = words [ 0 ] . charAt ( 0 ) . toUpperCase ( ) + words [ 0 ] . slice ( 1 ) ;
6
- return words . join ( " " ) ;
7
- }
2
+ let words : string [ ] = text . split ( ' ' ) ;
3
+ words [ 0 ] = words [ 0 ] . toLowerCase ( ) ;
4
+ words . sort ( ( a , b ) => a . length - b . length ) ;
5
+ words [ 0 ] = words [ 0 ] . charAt ( 0 ) . toUpperCase ( ) + words [ 0 ] . slice ( 1 ) ;
6
+ return words . join ( ' ' ) ;
7
+ }
You can’t perform that action at this time.
0 commit comments