LeetCode 14. Longest Common Prefix Solution Explained - Java

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


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

No one explains solutions better than you, thank you so much for these videos, they are helping me a lot in the process of getting ready for technical interviews!

atefe
Автор

Its insane how short this video is but you explained it better than all the long fancy videos. Thank you

joanmoralesf
Автор

I think it would be great if you would show 2 solutions. One with a slow run time and then the optimal solution such as this. It really helps to understand it even more. Either way awesome video

jay-wfft
Автор

Nice one. We can have a case inside for loop to break it when prefix length reaches zero to avoid continuing to loop when there's no scope of common prefix further.

prajwalshenoy
Автор

bro your explaining method is quite creative, out of 7 videos based on this that I'd WATCHED, this was the best!

ananyadutta
Автор

you can add a check for prefix length ==0 at the end of the while loop. Incase nothing matches with the 2nd string then no need to check with rest of the list. And instead of substringing every itteration you can keep track of right index and only substring when returning the result.

KhayamGondal
Автор

Dude, I am probably much older than you, but goddamn I am LOVING your explanations. Getting a chance to prep my interviews very efficiently!

vcfirefox
Автор

It was so nicely explained.
Thanks a lot!

tanyagoel
Автор

what a solution man thanks alot nick brother please continue making these videos.

u r just different when it comes to explaining in most optimised ways.

satyamgupta
Автор

Damn man that explanation was so smooth

bhargavvaddepally
Автор

such a clear approach! everytime i do leetcode and feel like wtf about a question, i come here to watch your tutorial and i understand the solution so clearly! thanks a lot, u have a great help dude!

poojaupadhyay
Автор

Why i didnt find your channel until now. Your explaination is crisp clear and very simple thankyou :)

simrankak
Автор

Best solution for this problem . Great approach and clear explanation Thanks !!!

saradham
Автор

You wrapped that up very smoothly. Thanks Nick🙂.

kshitijpandey
Автор

IN PYTHON
s=["flow", "flew", "flower"]
k=s[0]
flag=0
a=""
for x in range(len(k)):
for j in s[1:]:
if k[x]!=j[x]:
flag=1
else:
a=""+k[x]
if flag==1:
break
else:
print(a, end="")

aadhi_dinesh
Автор

thanks, tried many things for c# but kept falling out of bounds. This works and simple to understand

greatred
Автор

Could you explain why the time complexity is O(S), where S is the sum of all characters in all strings?

Ben-pbct
Автор

Wow man. I could have never thought of approaching this problem this way. Thanks a ton👍

brucewayne
Автор

got through 3 different videos for a good solution but nick is one who always gives the best approach, Appreciate bro

ChetanKhairnar
Автор

Kudos to such a clean explanation ! Thank you.

abhinav