Skip to content

Commit f86c802

Browse files
committed
docs: add number 27 and 28
1 parent be20a60 commit f86c802

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ In this project, I will try to solve leetcode challenges in rust.
1313
- [x] [13. Roman to interger](src/easy/roman_to_integer.rs)
1414
- [x] [14. Longest common prefix](src/easy/longest_common_prefix.rs)
1515
- [x] [21. Merge two sorted lists](src/easy/merge_two_sorted_lists.rs)
16+
- [x] [27. Remove element](src/easy/remove_element.rs)
17+
- [x] [28. Implement strStr()](src/easy/implement_strstr.rs)
1618
- [x] [234. Palindrome linked list](src/easy/palindrome_linked_list.rs)
1719

1820

src/easy/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub mod find_the_index_of_the_first_occurrence_in_a_string;
1+
pub mod implement_strstr;
22
pub mod longest_common_prefix;
33
pub mod merged_two_sorted_lists;
44
pub mod palindrome_linked_list;

src/easy/readme.md

+27
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,33 @@ Put the code below in main.rs and run `cargo run`
203203
println!("result: {:?}", result);
204204
```
205205

206+
# 28. Implement strStr()
207+
208+
## Description
209+
210+
Given a haystack string and a needle string, find the first occurrence of needle in haystack. If no needle is found, return -1.
211+
212+
## Examples
213+
```text
214+
Input: haystack = "hello", needle = "ll"
215+
Output: 2
216+
217+
Input: haystack = "aaaaa", needle = "bba"
218+
Output: -1
219+
```
220+
221+
## How to Run in main.rs
222+
223+
Put the code below in main.rs and run `cargo run`
224+
225+
```rust
226+
let haystack = String::from("hello");
227+
let needle = String::from("ll");
228+
let result = easy::implement_strstr::str_str(haystack, needle);
229+
println!("result: {:?}", result);
230+
```
231+
232+
206233

207234
# 234. Palindrome linked list
208235

0 commit comments

Comments
 (0)