20240422 Finished
This commit is contained in:
parent
ec7fc6a29e
commit
673a4a9388
|
@ -109,3 +109,4 @@ mod p135_candy;
|
||||||
mod p42_trapping_rain_water;
|
mod p42_trapping_rain_water;
|
||||||
mod p58_length_of_last_word;
|
mod p58_length_of_last_word;
|
||||||
mod p151_reverse_words_in_a_string;
|
mod p151_reverse_words_in_a_string;
|
||||||
|
mod p28_find_the_index_of_the_first_occurrence_in_a_string;
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* [28] Find the Index of the First Occurrence in a String
|
||||||
|
*/
|
||||||
|
pub struct Solution {}
|
||||||
|
|
||||||
|
|
||||||
|
// submission codes start here
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn str_str(haystack: String, needle: String) -> i32 {
|
||||||
|
match haystack.find(&needle) {
|
||||||
|
Some(pos) => pos as i32,
|
||||||
|
None => -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// submission codes end
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_28() {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user