Skip to content

Commit 1a4bec6

Browse files
committed
feat: add question 151
1 parent c3f18e1 commit 1a4bec6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

151.data

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"the sky is blue"
2+
" hello world! "
3+
"a good example"

151.翻转字符串里的单词.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* @lc app=leetcode.cn id=151 lang=javascript
3+
*
4+
* [151] 翻转字符串里的单词
5+
*
6+
* 1. 正则匹配分词
7+
* 2. 去掉空单词
8+
* 3. 顺序翻转
9+
* 4. 拼接单词
10+
*/
11+
12+
// @lc code=start
13+
/**
14+
* @param {string} s
15+
* @return {string}
16+
*/
17+
var reverseWords = function(s) {
18+
return s.split(/[ ]+/).filter(word => word).reverse().join(' ');
19+
};
20+
// @lc code=end
21+

0 commit comments

Comments
 (0)