20240422 Finished

This commit is contained in:
jackfiled 2024-04-22 10:00:39 +08:00
parent ec7fc6a29e
commit 673a4a9388
2 changed files with 29 additions and 1 deletions

View File

@ -108,4 +108,5 @@ mod p134_gas_station;
mod p135_candy;
mod p42_trapping_rain_water;
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;

View File

@ -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() {
}
}