Thank you for the content man. Your channel is so underrated. This is my go to channel now. Keep it up man and your channel will blow up! Like everybody said use the playlist feature for similar content it makes a huge difference.
Love this series! I'd love to see more of the thought process and what clues to look for in the challange description to structure the code. I'm a beginner and sometimes struggle with my weird thought processes! Thank you for the great vid!
These are amazing, and I'd love to see your breakdown of all the major sorting algorithms - along with a brief explanation of when it would be best to implement these types of sort
@@WebDevSimplified they only topic that doesn't put dust on internet is PROBLEM SOLVING. It's a win-win thing. You learn more you grow; you share it on RUclips channel grows! Do share and make it happen! ;)
I hope you could kindly show us how you create the video, all your technics help understanding while keeping all clean, very impressive, few can compete with you on this point. 👍
A python implementation people may find helpful. class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: longestPre = "" if strs: for i in range(len(strs[0])): char = strs[0][i] for j in range(len(strs)): try: if strs[j][i] != char: return longestPre except: return longestPre longestPre = longestPre + char return longestPre
I subscribed your channel after watching the first video. I would love to listen more of these algorithms from you. if possible can you make the video on Binary Search and Binary Tree?
That is on my list of todos. I have a Node.js MongoDB course that is free on RUclips and covers Node.js and MongoDB in depth if you want to check that out.
There is a bug in the code actually. For example, strs = ["ab", "a"] will throw an index out of range error, We are comparing all indexes of strings with string 1, which in our case is "ab". Second string is of length 1. So, accessing the index 1 will produce an error.
I am no JS expert, but I was wondering if the inner loop should start with j=1... since j = 0 would refer to the same string as the outer loop. Thanks.
I was thinking of this too but that would mess up the case if there was only one string. Great idea but you also would need to add if len(strs)==1 return strs[0]
What if the first word is a million characters long though? Should we first sort the words by length, or would that be even worse space-time complexity?
There is a bug here. Suppose the String[] strs = [apple, ape, a] Starting with i = 0, 'a' is added to prefix. (BUG HERE) Then i = 1, here there will be an ARRAYOUTOFBOUND for i = 1 , j = 2 ...strs[j][i] for last string 'a'.
Oh my bad! I used Java to program this and found it might give error. Thanks for reply and making this video! Otherwise I would have not understood concept of vertical scanning.
what is the pregress of two for loop in nested. Is the frist loop fn only execute one time then going into second loop fn, after second loop is finished* condition finished then return back to first loop for second time of first loop fn then go second loop fn again? hope helper can understand what i want to said =)
If you go to the leetcode link in the description they have breakdowns of all the different solutions and time complexities. While this is not the fastest method it is significantly easier and not much slower.
This is working for me on Leetcode but when I copy it into VS code it returns 'undefined' when I pass in the array - const test = ["flower","flow","flight"] console.log(longestCommonPrefix(test)) Has anyone got any idea why this might be? Thanks and great video!!
There is a bug in the code actually. For example, strs = ["flower", "flow", "flight"] will throw an index out of range error, We are comparing all indexes of strings with string 1, which in our case is "flower". Second string is of length 4. So, accessing the index 4 will produce an error.
Thank you for the content man. Your channel is so underrated. This is my go to channel now. Keep it up man and your channel will blow up! Like everybody said use the playlist feature for similar content it makes a huge difference.
Thanks! I have these algorithm videos already in a playlist and have many playlists for my similiar content on my channel.
This is the nicest explanation I have ever had! Please do more leetcode problems like this!
Love this series! I'd love to see more of the thought process and what clues to look for in the challange description to structure the code. I'm a beginner and sometimes struggle with my weird thought processes! Thank you for the great vid!
That is a great suggestion. I have another algorithm video coming out soon, so hopefully I explained it a bit more in depth for you.
These are amazing, and I'd love to see your breakdown of all the major sorting algorithms - along with a brief explanation of when it would be best to implement these types of sort
Thanks a lot bro! love your no nonsense teaching style. Please do more leetcode walkthroughs in the future.
I plan to keep covering them. They are fun to make.
You have "simplified" this algo with ease....Thank you...Wish for these kind of videos on algo everyday
I wish I had enough time to do that.
@@WebDevSimplified Hahaha
please make a series of this and never stop....thanks for everything. God bless you
I have a couple algorithm videos and plan to make more.
Man you should continue with this series ❤️
You are awesome!!
Great video! RUclips needs more of these algorithm videos.
Thanks!
I absolutely love this series!
Thank you! Great solution!
Have a series going through most of leetcode algo problems (easy/medium difficulties)! Great video!
That's the goal. I'm glad you enjoy them.
thank you so much! love this series please make more of algorithms series!
I plan to make quite a few more.
Thank you soo much for making this tutorial This helped me alot!! You are the best!!
This is great man, thank you so much for this.
well said and good audio quality
Dude, you are a true 'Algorithmist'🥰🥰
Just subscribed! The more you will share algorithms video the 10x more I am gonna share your algorithm video links with internet!
I'm really glad you enjoyed it.
@@WebDevSimplified they only topic that doesn't put dust on internet is PROBLEM SOLVING. It's a win-win thing. You learn more you grow; you share it on RUclips channel grows! Do share and make it happen! ;)
Well done!
Thank you for the video =) always look forward to these algorithm series.
You're welcome!
Just subbed. Your channel is gold!
I hope you could kindly show us how you create the video, all your technics help understanding while keeping all clean, very impressive, few can compete with you on this point. 👍
Thank you. What do you mean by showing you how to create the video?
Thank you for this awesome video!
Thank you Web Dev Simplified. This is good!
You're welcome!
thank you this helped alot !!
A python implementation people may find helpful.
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
longestPre = ""
if strs:
for i in range(len(strs[0])):
char = strs[0][i]
for j in range(len(strs)):
try:
if strs[j][i] != char:
return longestPre
except:
return longestPre
longestPre = longestPre + char
return longestPre
I love your channel man!
You are a pro, and your explanations are the best.
Can you please make a video on notifications in PWA?
Thanks
I plan to eventually jump into some PWA videos but I still have a lot of topics I want to cover first.
Well done, great explanation!
Thank you
That was nice problem to solve and great explanation from you, I’ll skip the code and write it by mslf🤍
Awesome tutorials like always!
Thanks!
beautiful amazing fantastic mind-cracking idea :))
Great topic and nice solution, Thanks
You're welcome!
I subscribed your channel after watching the first video. I would love to listen more of these algorithms from you. if possible can you make the video on Binary Search and Binary Tree?
You are doing great!!!
Please give as a full in-depth tutorial on MongoBD
And use some live example to use it on project
That is on my list of todos. I have a Node.js MongoDB course that is free on RUclips and covers Node.js and MongoDB in depth if you want to check that out.
Nice content and covered in a very nice way 🙏👍 thanx man🙏
You're welcome!
Legendary
There is a bug in the code actually. For example,
strs = ["ab", "a"] will throw an index out of range error,
We are comparing all indexes of strings with string 1, which in our case is "ab".
Second string is of length 1. So, accessing the index 1 will produce an error.
Yes, that's why you should sort the list with key=len first. Now you won't run in to index errors because you have the shortest member of the array.
@@woto6090 Why add O(nlogn) overhead, when you can make it work by slight if/else checks?
Also need php tutorials .great work
I probably won't be doing much PHP on this channel since I do not enjoy it as much and it is much less popular.
Make a video on Longest Common "Substring" for "more than two strings"
Hi, Great explanation. Can you please make a video of how to solve Maximum sum sub array problem using Kadane's Algorithm in Javascript?
I can look into it
Quick question.Shouldn't j loop start from 1 though ? Thanks for your videos dude.
Smart! Saves him the time of running it against the string he's already using as a reference.
Thank you so much. This was very useful
I'm glad you enjoyed it!
Thank You! just subscribed to your channel:)
it would be better if you had also covered the divide-and-conquer approach and binary-search approach to solve this problem.
Great video dude!
Thanks!
You're dope, brother.
I am no JS expert, but I was wondering if the inner loop should start with j=1... since j = 0 would refer to the same string as the outer loop. Thanks.
That is correct. Good catch!
I was thinking of this too but that would mess up the case if there was only one string. Great idea but you also would need to add if len(strs)==1 return strs[0]
Thanks a lot .... Best explanation ever!!! :D
I'm glad you enjoyed it!
great one!!!
Thanks!
Vertical method is very intuitive.
What if the first word is a million characters long though? Should we first sort the words by length, or would that be even worse space-time complexity?
thank you very much
You're welcome!
You could also use a trie.
Does this program use Big O notation?
more algorithm videos pls
Will do!
And binary search method man?
There is a bug here. Suppose the String[] strs = [apple, ape, a]
Starting with i = 0, 'a' is added to prefix.
(BUG HERE) Then i = 1, here there will be an ARRAYOUTOFBOUND for
i = 1 , j = 2 ...strs[j][i] for last string 'a'.
Javascript does not have array out of bounds errors. It just returns undefined if there is nothing at that index of the array.
Oh my bad! I used Java to program this and found it might give error.
Thanks for reply and making this video! Otherwise I would have not understood concept of vertical scanning.
@@vinamra4893 No worries. I am really glad you enjoyed the video.
Thx you got subscription by me
I can't do that, even you explain me, i guess that i have to really train in algorithmes
You have such a great demeanor. Keeeeeeep it up, bro. Maybe just get a light for your face, lol.
what is the pregress of two for loop in nested. Is the frist loop fn only execute one time then going into second loop fn, after second loop is finished* condition finished then return back to first loop for second time of first loop fn then go second loop fn again? hope helper can understand what i want to said =)
That is exactly what happens. Good analysis.
Anyone know the run time complexity of this solution? It's O(n^2) isn't it? I feel like there HAS to be a better way of doing this..
If you go to the leetcode link in the description they have breakdowns of all the different solutions and time complexities. While this is not the fastest method it is significantly easier and not much slower.
@@WebDevSimplified Ahh got it. Thank you!
["ab", "a"] = above code will fail for this case
Your solution won't work for ["ab", "a"]
A *P P* L
hair is so distracting :P
This is working for me on Leetcode but when I copy it into VS code it returns 'undefined' when I pass in the array -
const test = ["flower","flow","flight"]
console.log(longestCommonPrefix(test))
Has anyone got any idea why this might be?
Thanks and great video!!
There is a bug in the code actually. For example,
strs = ["flower", "flow", "flight"] will throw an index out of range error,
We are comparing all indexes of strings with string 1, which in our case is "flower".
Second string is of length 4. So, accessing the index 4 will produce an error.