Longest Palindromic Substring - LeetCode (Solution & Explanation | JavaScript)

  Рет қаралды 14,974

shirin setayesh

shirin setayesh

Күн бұрын

Пікірлер: 40
@snoudoubts1745
@snoudoubts1745 3 жыл бұрын
Had a hard time understanding wrapping my head around the center expansion for odd/even numbered palindrome. Shows again why visualization is so so so important. Thanks for the video! Subscribed.
@lornamuchangi1223
@lornamuchangi1223 2 жыл бұрын
We are checking from center ever possible palindrome.
@paulgz101
@paulgz101 Жыл бұрын
Best explanation of this problem. Thanks!
@ishaan380
@ishaan380 3 жыл бұрын
After watching couple of videos I can surely say this is the shortest and best video for this problems solution in O(n^2)
@StaceyWilsonlosangeles
@StaceyWilsonlosangeles 3 жыл бұрын
Okay, I would say that your explanation is great. Very intuit thought process for handling even and odd palindromic strings. Great Job!
@linlinli2440
@linlinli2440 3 жыл бұрын
I really like your explaination!! so simple and easy to understand! thank you!! please keep updated!!!
@harshnamdeo613
@harshnamdeo613 Жыл бұрын
thanks for this video!!! i was going through the same approach but wasn't able to find my error !!!! thanks buddy....
@mohammedfaseeullah6095
@mohammedfaseeullah6095 Жыл бұрын
Hi , why i-- is used at last , could you explain 6:57
@trytocreatesomethingnew8564
@trytocreatesomethingnew8564 Жыл бұрын
I'm also confused in that line
@santiderek
@santiderek 2 жыл бұрын
why did you do i-- outside the while loop? can you explain that part please
@christianhurtadocatacoli1757
@christianhurtadocatacoli1757 Жыл бұрын
I think this has to do with the i representing the current pointers. She’s adding it ahead of time, instead of peaking so to speak. For example “abcbd” The function checks if c === c (so she adds 1), Now she checks if b === b (so i becomes 2), Then we check a === d which violates the palindrome and therefore the length we’re at is incorrect and reverts back to the most recent acceptable palindrome length, 1 giving us the slice “bcb”
@mosoakinyemi
@mosoakinyemi Жыл бұрын
@@christianhurtadocatacoli1757 Thanks for this breakdown!
@akshaynair3787
@akshaynair3787 4 жыл бұрын
Thank you, the approach is really good
@rusiruabeywickrama
@rusiruabeywickrama 2 жыл бұрын
The space complexity for this solution is not O(1). It is actually O(n), Due to the fact that we slice the string and take the substring that substring length depend on the size of the string passed to the function. In the worse case there can be a string in which the full length of passed string can be a palindrome in that case the when we splice the main string into substring the code will actually perform a function that depend on the be n number of size where n is the length of passed string.
@4maxlol
@4maxlol 2 жыл бұрын
Yes.
@TechAndTravel-ny8tx
@TechAndTravel-ny8tx 2 жыл бұрын
Cheers!
@rajansidhu5912
@rajansidhu5912 2 жыл бұрын
Amazing explanation. Thanks for the video :)
@DanOhCaptainDaniel
@DanOhCaptainDaniel 3 жыл бұрын
for some reason didn't pass for me, medium , explore page
@PlumsYT
@PlumsYT 2 жыл бұрын
something about this just makes me feel like a hotdog without a bun
@gulinatayier9049
@gulinatayier9049 3 жыл бұрын
Great explaination! Thank you!
@PavanKumar-mr9td
@PavanKumar-mr9td 3 жыл бұрын
Awesome explanation super................
@carlosvenegas8981
@carlosvenegas8981 3 жыл бұрын
good solution! I had a hard time understanding what was happening, so i followed the code step by step in debugger to understand how it solved the problem, then the solution made sense for me. Unfortunately for me her explanation didn't make sense to me.
@darshitgajjar5199
@darshitgajjar5199 10 ай бұрын
more video like this
@betheleyo2701
@betheleyo2701 3 жыл бұрын
Great stuff. Thanks
@mrnabby4178
@mrnabby4178 2 жыл бұрын
could you please make another video about palindromic substrings plz?
@fernandotoledo8093
@fernandotoledo8093 2 жыл бұрын
from input "aaabb" I'm expecting this result: "ababa"; how do you pass this test case?
@tornike9018
@tornike9018 2 жыл бұрын
thank you very much,works properly
@mohitnegi724
@mohitnegi724 Жыл бұрын
Thanks
@felipemelendez5741
@felipemelendez5741 3 жыл бұрын
Thank you!
@datjoe6273
@datjoe6273 Жыл бұрын
I'm seeing this fail with 'abb' on LC. Returns 'b' instead of 'bb.' It works with the example test cases.
@markmathis3954
@markmathis3954 4 жыл бұрын
why did you add the `i--`
@vsworx
@vsworx 4 жыл бұрын
I had the same question. Did you ever find out why the i-- is there.
@akshaynair3787
@akshaynair3787 4 жыл бұрын
@@vsworx coz the I will go and stop at place where the string are not palindrome, right? But u don't want that, so i-- decrease one string where it was palindrome previous and return the value
@muazothman7416
@muazothman7416 3 жыл бұрын
@@akshaynair3787 yes you are right: if i is not decremented then it would be incremented and then it would break out of the while loop. So you want to decrement it to when the last iteration was true inside the while loop -- get it?
@fixcodedesign2165
@fixcodedesign2165 2 жыл бұрын
please try this input "cbbd"
@thegeeksides
@thegeeksides 3 жыл бұрын
This wouldnt pass the test case: ac
@alirezafirouzyar9425
@alirezafirouzyar9425 4 жыл бұрын
this code will not pass other Testcase
@vsworx
@vsworx 4 жыл бұрын
Interesting, what other testcases are you referring to?
@snoudoubts1745
@snoudoubts1745 3 жыл бұрын
@@vsworx seems like doesn't pass "cbbd"
@rubytyt9851
@rubytyt9851 2 жыл бұрын
The solution doesn't cover all cases.
Move Zeroes - LeetCode (Solution & Explanation | JavaScript)
4:02
shirin setayesh
Рет қаралды 2,6 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 22 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,3 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
LeetCode 5.  Longest Palindromic Substring (Algorithm Explained)
14:40
Longest Palindrome - Leetcode 409 - Python
12:20
NeetCodeIO
Рет қаралды 15 М.
Longest Palindromic Substring Manacher's Algorithm
16:46
Tushar Roy - Coding Made Simple
Рет қаралды 346 М.
DP 28. Longest Palindromic Subsequence
9:38
take U forward
Рет қаралды 270 М.
Pascal's Triangle - LeetCode (Solution & Explanation | JavaScript)
7:48
Why Is Lua So Popular?
8:03
Awesome
Рет қаралды 101 М.
Israel Has The Right To Defend Itself | Stand-up Comedy by Daniel Fernandes
15:07
How I Got Good at Coding Interviews
6:29
NeetCode
Рет қаралды 1,7 МЛН
Manacher's Algorithm | Longest Palindromic Substring
21:47
Fluent Algorithms
Рет қаралды 30 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН