MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / count_asterisks

Function count_asterisks

2315-count-asterisks.rs:1–18  ·  view source on GitHub ↗
(s: String)

Source from the content-addressed store, hash-verified

1pub fn count_asterisks(s: String) -> i32 {
2 let mut outside = true;
3 let mut tmp_s = String::new();
4 for c in s.chars() {
5 if outside {
6 if c != '|' {
7 tmp_s.push(c);
8 } else {
9 outside = false;
10 }
11 } else {
12 if c == '|' {
13 outside = true;
14 }
15 }
16 }
17 tmp_s.matches(|c|c=='*').count() as i32
18}
19
20fn main() {
21 println!("{:?}",count_asterisks("yo|uar|e**|b|e***au|tifu|l".to_string()));

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected