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

Function find_ocurrences

1078-occurrences-after-bigram.rs:1–11  ·  view source on GitHub ↗
(text: String, first: String, second: String)

Source from the content-addressed store, hash-verified

1pub fn find_ocurrences(text: String, first: String, second: String) -> Vec<String> {
2 let strs: Vec<String> = text.split(" ").map(|s|s.to_string()).collect();
3 let tail_index = &strs.len() - 2;
4 let mut res: Vec<String> = Vec::new();
5 for i in 0..tail_index {
6 if strs[i] == first && strs[i+1] == second {
7 res.push(strs[i+2].clone());
8 }
9 }
10 res
11}
12
13fn main() {
14 let text = "we will we will rock you".to_string();

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected