28. Find the Index of the First Occurrence in a String | JavaScript | LeetCode Daily Challenge
Join my Discord channel / discord
I have created a detailed solution to the problem along with examples.
Solution: leetcode.com/problems/find-th...
Problem: leetcode.com/problems/find-th...
I have created a detailed video solution for the leetcode daily challenge.
#javascript #leetcode #leetcodedailychallenge #coding
Connection Info:
LeetCode: leetcode.com/monuchaudhary1/
LinkedIn: / monu-chaudhary
Instagram: / monu.chaudhary9
Пікірлер: 11
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.
@LeetCodeWithMonu
Жыл бұрын
Thank you for supporting. Feedbacks like yours keep me motivated to create more informative videos.
Wow, literally best video explanation I've seen. Keep it up!
@LeetCodeWithMonu
Жыл бұрын
Thanks, will do!
The time complexity on which you solved is O(n^2). This problem can be solved in O(n) using KMP string search algorithm.
@LeetCodeWithMonu
10 ай бұрын
thanks for mentioning this
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?
@joydeep_
Ай бұрын
Its probably best because its a standard function, but that does not test your logical ability right.
will you please add deocde string problem
@LeetCodeWithMonu
Жыл бұрын
Always. Let me know if you need help with any LeetCode problem.
var strStr = function (haystack, needle) { let pointer = 0; for (let i = 0; i if (haystack[i] !== needle[pointer]) { i = i - pointer; pointer = 0; } else if (pointer === needle.length - 1) { return i - pointer; } else{ pointer ++; } } return -1; };