Skip to content

Commit

Permalink
0039.组合总和
Browse files Browse the repository at this point in the history
  • Loading branch information
aouos committed May 26, 2021
1 parent 49d45cf commit 29ea3ad
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion problems/0039.组合总和.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,32 @@ class Solution:
```
Go:


JavaScript
```js
var strStr = function (haystack, needle) {
if (needle === '') {
return 0;
}

let hayslen = haystack.length;
let needlen = needle.length;

if (haystack === '' || hayslen < needlen) {
return -1;
}

for (let i = 0; i <= hayslen - needlen; i++) {
if (haystack[i] === needle[0]) {
if (haystack.substr(i, needlen) === needle) {
return i;
}
}
if (i === hayslen - needlen) {
return -1;
}
}
};
```


-----------------------
Expand Down

0 comments on commit 29ea3ad

Please sign in to comment.