Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findStartingIndex(T, pattern) {
- let S = T;
- const res = [];
- while(true) {
- const i = S.indexOf(pattern);
- if (i === -1) { return res; }
- S = S.substring(i + 1);
- res.push(i ? i + 1 : i);
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement