Skip to content

Commit c60e9c0

Browse files
authored
feat: add typescript solution to lc problem: No.0151.Reverse Words in a String (doocs#435)
1 parent db15933 commit c60e9c0

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

solution/0100-0199/0151.Reverse Words in a String/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ public class Solution {
113113
}
114114
```
115115

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+
116126
### **...**
117127

118128
```

solution/0100-0199/0151.Reverse Words in a String/README_EN.md

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ public class Solution {
9898
}
9999
```
100100

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+
101111
### **...**
102112

103113
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function reverseWords(s: string): string {
2+
let words: string[] = s.trim().split(/\s+/g);
3+
words.reverse();
4+
return words.join(' ');
5+
};

0 commit comments

Comments
 (0)