feat: add initial implementation of Cargo.toml, Cargo.lock, and lib.rs with find_words_containing function
This commit is contained in:
parent
50d62c34be
commit
21fffd8882
7
2942_find_words_containing_character/Cargo.lock
generated
Normal file
7
2942_find_words_containing_character/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "find_words_containing_character"
|
||||||
|
version = "0.1.0"
|
6
2942_find_words_containing_character/Cargo.toml
Normal file
6
2942_find_words_containing_character/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "find_words_containing_character"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
12
2942_find_words_containing_character/src/lib.rs
Normal file
12
2942_find_words_containing_character/src/lib.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pub struct Solution;
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn find_words_containing(words: Vec<String>, x: char) -> Vec<i32> {
|
||||||
|
words
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter(|(_, word)| word.contains(x))
|
||||||
|
.map(|(index, _)| index as i32)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user