Skip to content

Commit ec67269

Browse files
BarklimBarklim
authored andcommitted
Create 0028.js
1 parent b06f321 commit ec67269

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

0028-implement-strstr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ var strStr = function(haystack, needle) {
2424
const split = haystack.split(needle);
2525
return split.length > 1 ? split[0].length : -1;
2626
};
27+
28+
// var strStr = function(haystack, needle) {
29+
// return haystack.indexOf(needle)
30+
// };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {string} haystack
3+
* @param {string} needle
4+
* @return {number}
5+
*/
6+
var strStr = function(haystack, needle) {
7+
8+
};
9+
10+
const example1 = strStr("sadbutsad", "sad"); // 0
11+
const example2 = strStr("leetcode","leeto"); // -1
12+
const example3 = strStr("bro", "rosb"); // -1
13+
const example4 = strStr("asasadbutsad", "sad"); // 3
14+
15+
console.log(example1);
16+
console.log(example2);
17+
console.log(example3);
18+
console.log(example4);

example/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Better order to solve problems
4343
0.
4444
121. Best Time to Buy and Sell Stock
4545
424. Longest Repeating Character Replacement
46+
- 424. Longest Repeating Character Replacement
47+
- 567. Permutation in String
48+
- 76. Minimum Window Substring
49+
- 239. Sliding Window Maximum
4650

4751
### Linked list
4852

@@ -202,4 +206,5 @@ Better order to solve problems
202206
### [0.Basic](https://github.com/Barklim/leetcode-javascript/tree/master/example/ProgrammingSkills/0.Basic)
203207

204208
1768. Merge Strings Alternately
205-
389. Find the Difference
209+
389. Find the Difference
210+
28. Find the Index of the First Occurrence in a String

0 commit comments

Comments
 (0)