mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
更新 0028.实现strStr Rust版本多余代码删除
This commit is contained in:
@ -1314,7 +1314,6 @@ impl Solution {
|
|||||||
|
|
||||||
pub fn str_str(haystack: String, needle: String) -> i32 {
|
pub fn str_str(haystack: String, needle: String) -> i32 {
|
||||||
let (haystack_len, needle_len) = (haystack.len(), needle.len());
|
let (haystack_len, needle_len) = (haystack.len(), needle.len());
|
||||||
if haystack_len == 0 { return 0; }
|
|
||||||
if haystack_len < needle_len { return -1;}
|
if haystack_len < needle_len { return -1;}
|
||||||
let (haystack, needle) = (haystack.chars().collect::<Vec<char>>(), needle.chars().collect::<Vec<char>>());
|
let (haystack, needle) = (haystack.chars().collect::<Vec<char>>(), needle.chars().collect::<Vec<char>>());
|
||||||
let mut next: Vec<usize> = vec![0; haystack_len];
|
let mut next: Vec<usize> = vec![0; haystack_len];
|
||||||
@ -1355,9 +1354,6 @@ impl Solution {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
pub fn str_str(haystack: String, needle: String) -> i32 {
|
pub fn str_str(haystack: String, needle: String) -> i32 {
|
||||||
if needle.is_empty() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if haystack.len() < needle.len() {
|
if haystack.len() < needle.len() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user