28. Find the Index of the First Occurrence in a String | JavaScript | LeetCode Daily Challenge

preview_player
Показать описание

I have created a detailed solution to the problem along with examples.

I have created a detailed video solution for the leetcode daily challenge.
#javascript #leetcode #leetcodedailychallenge #coding

Connection Info:
Рекомендации по теме
Комментарии
Автор

Great video! I really enjoyed watching it. Your problem-solving methods are very nice and easy to understand. Keep doing what you're doing. You deserve more subscribers for the effort you put into making such informative and helpful content.

gowthamtalkies
Автор

Wow, literally best video explanation I've seen. Keep it up!

mrawesome
Автор

The time complexity on which you solved is O(n^2). This problem can be solved in O(n) using KMP string search algorithm.

sauravrath
Автор

var strStr = function (haystack, needle) {
let pointer = 0;
for (let i = 0; i < haystack.length; i++) {
if (haystack[i] !== needle[pointer]) {
i = i - pointer;
pointer = 0;
}
else if (pointer === needle.length - 1) {
return i - pointer;
}
else{
pointer ++;
}
}
return -1;
};

agtech
Автор

hello! why is my solution 'return haystack.indexOf(needle)' bad? i don't know much about time complexity and etc. because I mainly practice web development, but I've heard of it. can you explain why my answer would be bad?

juxtapose
Автор

will you please add deocde string problem

sankaranarayanankm
visit shbcf.ru