Skip to content

Commit e4fc31a

Browse files
committed
Upsert 434-number-of-segments-in-a-string.rs
1 parent 77ca029 commit e4fc31a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

434-number-of-segments-in-a-string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub fn count_segments(s: String) -> i32 {
2+
s.split_ascii_whitespace().count() as i32
3+
}
4+
5+
fn main() {
6+
println!("{:?}", count_segments("s Hello, my name is John".to_string()));
7+
}

0 commit comments

Comments
 (0)