File tree 3 files changed +25
-0
lines changed
solution/0100-0199/0151.Reverse Words in a String
3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,16 @@ public class Solution {
113
113
}
114
114
```
115
115
116
+ ### ** TypeScript**
117
+
118
+ ``` ts
119
+ function reverseWords(s : string ): string {
120
+ let words: string [] = s .trim ().split (/ \s + / g );
121
+ words .reverse ();
122
+ return words .join (' ' );
123
+ };
124
+ ```
125
+
116
126
### ** ...**
117
127
118
128
```
Original file line number Diff line number Diff line change @@ -98,6 +98,16 @@ public class Solution {
98
98
}
99
99
```
100
100
101
+ ### ** TypeScript**
102
+
103
+ ``` ts
104
+ function reverseWords(s : string ): string {
105
+ let words: string [] = s .trim ().split (/ \s + / g );
106
+ words .reverse ();
107
+ return words .join (' ' );
108
+ };
109
+ ```
110
+
101
111
### ** ...**
102
112
103
113
```
Original file line number Diff line number Diff line change
1
+ function reverseWords ( s : string ) : string {
2
+ let words : string [ ] = s . trim ( ) . split ( / \s + / g) ;
3
+ words . reverse ( ) ;
4
+ return words . join ( ' ' ) ;
5
+ } ;
You can’t perform that action at this time.
0 commit comments