更新 0028.实现strStr Rust版本多余代码删除

This commit is contained in:
Charlie
2023-04-23 14:55:28 +08:00
parent 3466eda7dc
commit 9558af957b

View File

@ -1314,7 +1314,6 @@ impl Solution {
pub fn str_str(haystack: String, needle: String) -> i32 {
let (haystack_len, needle_len) = (haystack.len(), needle.len());
if haystack_len == 0 { return 0; }
if haystack_len < needle_len { return -1;}
let (haystack, needle) = (haystack.chars().collect::<Vec<char>>(), needle.chars().collect::<Vec<char>>());
let mut next: Vec<usize> = vec![0; haystack_len];
@ -1355,9 +1354,6 @@ impl Solution {
next
}
pub fn str_str(haystack: String, needle: String) -> i32 {
if needle.is_empty() {
return 0;
}
if haystack.len() < needle.len() {
return -1;
}