Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e4d08f

Browse files
committed
add: number-of-segments-in-a-string.js
1 parent2f26845 commit5e4d08f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎src/number-of-segments-in-a-string.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
3+
*
4+
* Please note that the string does not contain any non-printable characters.
5+
*
6+
* number-of-segments-in-a-string.js
7+
*@authors Joe Jiang (hijiangtao@gmail.com)
8+
*@date 2017-02-12 12:50:48
9+
*@param {string} s
10+
*@return {number}
11+
*/
12+
13+
letcountSegments=function(s){
14+
s=s.trim()
15+
if(s){
16+
letre=newRegExp(' +');
17+
returns.split(re).length;
18+
}
19+
20+
return0;
21+
};

‎src/two-sum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* You may assume that each input would have exactly one solution, and you may not use the same element twice.
55
*
6-
*two0sum.js
6+
*two-sum.js
77
*
88
*@param {number[]} nums
99
*@param {number} target

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp