LeetCode Solution - 5.0 Longest Palindromic Substring | Manacher Algorithm 100% Beat

  Рет қаралды 11,891

ThinkFWD

ThinkFWD

Күн бұрын

Пікірлер: 28
@TauassarTatiyev
@TauassarTatiyev Ай бұрын
I spent the entire evening trying to understand this algorithm, and your video was a great help. Thank you so much!
@ThinkFWD
@ThinkFWD Ай бұрын
Thank you!
@RichardYoung11
@RichardYoung11 4 жыл бұрын
I'm currently working through the Blind 75 Leetcode list, and I find your videos to be super helpful! Most explanations I find are in Java or Python, and it's great to see some JavaScript solutions. Personally, I like the background music. It's like watching a relaxing Twitch stream. Please keep it up!
@ThinkFWD
@ThinkFWD 4 жыл бұрын
Richard Young thanks man! I might bring back some soothing background music
@MarcRacho
@MarcRacho 4 жыл бұрын
Ok, this confused me a lot lol but I did some more reading about the algorithm, plus actually running the algorithm on paper, tracking every variable, helped a lot. I have never heard of Manacher algorithm until this video. Thanks again, bro!
@ThinkFWD
@ThinkFWD 4 жыл бұрын
please feel free to recommend a question for next eps !
@meeravalinawab9372
@meeravalinawab9372 4 жыл бұрын
Bro you are best in explaining things bro love this video. Searching for this actually messed my interview because of this algorithm
@meeravalinawab9372
@meeravalinawab9372 4 жыл бұрын
Can you explain Tim sort bro . it will be helpful for cp.
@techmadehere
@techmadehere 4 жыл бұрын
KMP
@khandakermushfiqurrahman5117
@khandakermushfiqurrahman5117 4 жыл бұрын
Thank you for this great explanation. I learned the algorithm from you. Here is my python3 solution: (it got faster than 92% solutions status. not 100% . not sure why though) def preprocessString(s:str): l=len(s) retStr = [None]*(l*2+1) retStr[0]="#" j=1 for i in range(l): retStr[j]=s[i] retStr[j+1]="#" j+=2 return retStr class Solution: def longestPalindrome(self,s: str) -> str: ppStr=preprocessString(s) lenCount=[0]*len(ppStr) if len(s)
@ThinkFWD
@ThinkFWD 4 жыл бұрын
Well 92% is still fantastic. Sometimes Leetcode isn't the most accurate measure of %. It really depends on the server latency and how many people are hitting it at once. You can actually submit the same code again and get different specs. What i like to do is actually take an avg or at least your in the top percentile. The more important part is to understand the algorithm and not focus too much on the % etc. :) in real life, you have other ways to measure performance.
@RoundAboutMk
@RoundAboutMk 4 жыл бұрын
In my opinion, this is the best explanation of this algorithm on the internet. Thank you very much
@ThinkFWD
@ThinkFWD 4 жыл бұрын
Thank you for the positive feedback!
@sakthim7160
@sakthim7160 3 жыл бұрын
you have really explained well. Thank you.
@rajhpking
@rajhpking 4 жыл бұрын
No need of background music. For me it is really disturbing and I am not able to concentrate what you are explaining. Plz take off it.
@ThinkFWD
@ThinkFWD 4 жыл бұрын
Parag thanks I’ll note that for next video and keep it out :)
@MrMaxKey
@MrMaxKey 4 жыл бұрын
good demo but unfortunately no explanation why the algorithm works
@shubhamholkar8396
@shubhamholkar8396 5 ай бұрын
In an interview, I can do this and then try to optimize right. This is without knowing that algo. I just want to know if it is good as the first solution in the interview and then try to optimize it??? var longestPalindrome = function(s) { const split = s.split('').join('$').split('') const aa= s.split('') if(aa.reverse().join('')===s){ return s } if(s.length===2){ if(s[0]===s[1]){ return s } else{ return s[0] } } let longPal=s[0] for(let i =0; i{ while(arr[left] === arr[right] ){ left = left -1 right = right +1 } return { left, right} }
@techmadehere
@techmadehere 4 жыл бұрын
It was nice
@ThinkFWD
@ThinkFWD 4 жыл бұрын
Nimish Agrawal thanks !
@MrZiyak99
@MrZiyak99 4 жыл бұрын
why let right = i + (P[i] + 1) let left = i - (P[i] + 1) instead of let right = i + 1 let left = i - 1
@Ki1ngOfGods
@Ki1ngOfGods 2 жыл бұрын
As much as I wanted to understand this problem from different videos, I just couldn't. If I'm not mistaken isn't this O(n2)? Any simpler shorter way of solving it?
@nbf7004
@nbf7004 3 жыл бұрын
not a great explanation. didn't explain how the algorithm works.
@DMWestWoodElite
@DMWestWoodElite 4 жыл бұрын
I was able to solve the leetcode problem in python using this video, i still don't really understand the algorithm though.
@parthpatel-dg3db
@parthpatel-dg3db 4 жыл бұрын
Great Video. I liked it. But I am in doubt that It won't work for the string "ababababababa". Please try it out.
@karolrvn
@karolrvn 3 жыл бұрын
need more visible (bigger) mouse pointer
@Gel1098
@Gel1098 4 жыл бұрын
@10:31 Why not 1 or 3 = (10-7)?
@ThinkFWD
@ThinkFWD 4 жыл бұрын
gel drif great find! Apparently I cannot do mental math, you are correct it should be minimum of 1 or 3. The solution doesn’t change but what I mention (2) is incorrect.
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 18 МЛН
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 124 МЛН
Girl, dig gently, or it will leak out soon.#funny #cute #comedy
00:17
Funny daughter's daily life
Рет қаралды 18 МЛН
Leetcode 5. Longest Palindromic Substring
23:52
Code with Alisha
Рет қаралды 47 М.
LeetCode 5.  Longest Palindromic Substring (Algorithm Explained)
14:40
Longest Palindromic Substring O(N) Manacher's Algorithm
23:49
IDeserve
Рет қаралды 172 М.
49. Group Anagrams | Javascript
18:58
ThinkFWD
Рет қаралды 6 М.
Manacher's Algorithm | Longest Palindromic Substring
21:47
Fluent Algorithms
Рет қаралды 28 М.
Leetcode problem Longest Palindromic Substring (two solutions)
25:19
Errichto Algorithms
Рет қаралды 162 М.
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 18 МЛН