Manacher's Algorithm | Code Tutorial and Explanation

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024
  • Free-To-Use Developer ToolBox: developertoolb...
    How to Micro SaaS side-hustle: quinston.com/m...
    The Code can be found at:
    quinston.com/c...
    github.com/gra...
    ❌ Do not click this link: bit.ly/dont-eve...
    I do not claim to own any of the code explained in the video unless I explicitly mention that I own the code. It is usually inspired by various websites and I have tried to make some of my own changes for the sake of this tutorial.
    Send me an email or comment below if you want to be credited.

ความคิดเห็น • 66

  • @DemonSlayer13375
    @DemonSlayer13375 4 ปีที่แล้ว +14

    The explanation was great, but I found the background kind of distracting. I think it'd be easier to focus on the algorithm without all of the background noise

  • @tuhinmukherjee8141
    @tuhinmukherjee8141 3 ปีที่แล้ว +1

    Honestly, I wouldn't recommend this to anyone.

  • @harikiranvusirikala
    @harikiranvusirikala 7 ปีที่แล้ว +5

    I liked ur video, but better explain the code along with taking an example simultaneously, Thank for code.

    • @quinston
      @quinston  7 ปีที่แล้ว +3

      YO! Feedback taken! Thanks!

  • @abhijeetshuklaoist
    @abhijeetshuklaoist 3 ปีที่แล้ว

    Till 4 minutes mark, this video was good but I could not understand anything after that and that exactly is the crux of Manacher's algorithm.

  • @joshuashevitz2962
    @joshuashevitz2962 4 ปีที่แล้ว +2

    I think I got lost. When the pointer was at the hash on the right of b (I = 3) I don't understanding picking between the center or R-pointer

  • @MRaj-xz5kq
    @MRaj-xz5kq 6 ปีที่แล้ว +13

    Great video but the background distracts a bit. So try to keep it as simple as possible.

  • @TheAceInfinity
    @TheAceInfinity 3 ปีที่แล้ว

    The background video is super distracting from the main material.

  • @jianingzhuang104
    @jianingzhuang104 4 ปีที่แล้ว +3

    Best video I can find for Manacher's Algorithm!

  • @samiahmadkhan2865
    @samiahmadkhan2865 3 ปีที่แล้ว

    worst explanation ever. Made me more confused than ever

  • @peixinlin9670
    @peixinlin9670 5 ปีที่แล้ว +8

    I watched couples of videos about Manacher' algorithm and this is the best one for me!

  • @АсылжанНурлыбекулы-ч1ш
    @АсылжанНурлыбекулы-ч1ш 3 ปีที่แล้ว

    Good explanation, but weak example.

  • @flyingtiger123
    @flyingtiger123 ปีที่แล้ว +1

    In the expansion part, i guess you miss a condition that the i-1-p[i] or i+1+p[i] may run out of bound

  • @jeremybrocast
    @jeremybrocast 3 หลายเดือนก่อน

    thank you!

  • @mathguy198
    @mathguy198 2 ปีที่แล้ว +1

    Thanks man for such a nice and easy explanation to such a complex algorithm.

  • @vishalagrawal7651
    @vishalagrawal7651 5 ปีที่แล้ว +1

    absolutely amazing video,plzz keep making these videos

  • @partheshsoni6421
    @partheshsoni6421 5 ปีที่แล้ว +1

    Wow man, how can such a nice tutorial and channel went unnnoticed on YT!!

  • @SuperMaDBrothers
    @SuperMaDBrothers 4 ปีที่แล้ว +1

    The background gave me a seizure

  • @maneeshreddy3825
    @maneeshreddy3825 5 ปีที่แล้ว +1

    Best explanation of manacher's algorithm on youtube

  • @manishkumar-cu3sb
    @manishkumar-cu3sb 3 ปีที่แล้ว

    Nicely explained...I did not get what is the use of min(R-i,p[i_mirror] you should have taken p[i]=p[i_mirror] then also it will get same result ??

  • @chunxinchu2037
    @chunxinchu2037 6 ปีที่แล้ว

    line 91 of your code: while (str[i + 1 + P[i]] == str[i - 1 - P[i]]){
    P[i]++;
    }
    why do you need to check if (I==R)? Which means you only need to expand when you reach the R boundary of the palindrom? Thanks

  • @andaouyang135
    @andaouyang135 5 ปีที่แล้ว

    For the while loop in line 91: while (str[i+1+P[i]] == str[i-1-P[i]])), the index of string may be negtive. For example, when i = 0, P[i] = 0, then i-1-P[i] = -1 < 0. So I think such a line should be replaced by: while (i-1-p[i] >= 0 && i + 1 + p[i] < length && T[i + 1 + p[i]] == T[i-1-p[i]])?

  • @MrMaxKey
    @MrMaxKey 4 ปีที่แล้ว

    good demo, but unfortunately no explanation why it works

  • @Darkmatterkun
    @Darkmatterkun 11 หลายเดือนก่อน

    This was a really clear and concise algorithm! Really appreciate your work.

  • @btSehajbirSingh
    @btSehajbirSingh 3 ปีที่แล้ว

    The best and easiest video you can get for Manacher's Algorithm!! Keep up the positivity in ur videos....

  • @dragosc8202
    @dragosc8202 3 ปีที่แล้ว

    Thank you so much, finally understood it!

  • @chinmayapanigrahi7642
    @chinmayapanigrahi7642 4 ปีที่แล้ว

    Your explanation is mind blowing and i appreciate that.
    But your implementation fails for input - "bb" .

    • @hritikhanda630
      @hritikhanda630 4 ปีที่แล้ว

      you can simply solve that by applying a more condition
      if(c>=r||a.charAt(c)==a.charAt(c-2)) //Duplicate entries
      {
      expand and assign l, r, mirror;
      }

  • @ahusain1462
    @ahusain1462 6 ปีที่แล้ว

    Like he said, Manacher's Algorithm is not easy to understand. But this is a very good explanation. Thanks for this.

  • @lipimaheshbhaishah9548
    @lipimaheshbhaishah9548 4 ปีที่แล้ว

    I really appreciate your work and found one of the best videos about Manacher's algorithm. One request if you also can provide the same code in java as well, it will be really appreciated. Thank you.

  • @simeonarabov6379
    @simeonarabov6379 7 ปีที่แล้ว

    Could you please help me aquire the set of Preffix and Suffix Palindromes. That is all palindromes starting at i = 1 or ending at i = s.length().

  • @go_cool_travels
    @go_cool_travels 4 ปีที่แล้ว +2

    While watching for the first time!! Wow that background graphics looking awesome.
    #amIonlyOne

  • @adithyabhat4770
    @adithyabhat4770 4 ปีที่แล้ว

    incredible incredible lol

  • @xayah3375
    @xayah3375 5 ปีที่แล้ว

    Well explained video, thx.XD

  • @nishanktripathi6589
    @nishanktripathi6589 4 ปีที่แล้ว

    This is the best explanation I found 🙏

  • @shikharchaudhary6984
    @shikharchaudhary6984 4 ปีที่แล้ว

    Good work.

  • @chunxinchu2037
    @chunxinchu2037 6 ปีที่แล้ว

    Fantastic! This is the best explanation which is easiest to understand so far!

  • @mastrake
    @mastrake 7 ปีที่แล้ว

    Great explanation! I do see a minor problem at line 91 where on iteration 0, the expression "i - 1 - P[i] results in an index of -1.

    • @quinston
      @quinston  7 ปีที่แล้ว

      Does it give you an error?

    • @mastrake
      @mastrake 7 ปีที่แล้ว

      It works for me but can fail depending on what value happens to be at the address of str minus 1 in storage.

    • @KarthikArji
      @KarthikArji 5 ปีที่แล้ว

      @@quinston yeah i got an error. Please tell me the solution for it

  • @rasmiranjanbabu
    @rasmiranjanbabu 7 ปีที่แล้ว

    Liked the code walk through

  • @zhuzhuqing4862
    @zhuzhuqing4862 5 ปีที่แล้ว

    amazing!

  • @honeybunnysugarpie
    @honeybunnysugarpie 6 ปีที่แล้ว

    I understood thanks to you

  • @cagmz
    @cagmz 6 ปีที่แล้ว

    Nice work

  • @scotl33t
    @scotl33t 6 ปีที่แล้ว

    Well done mate!

  • @grijeshmnit
    @grijeshmnit 5 ปีที่แล้ว +1

    Get a down vote me! Better luck next time. Thanks

  • @vishalagrawal7651
    @vishalagrawal7651 5 ปีที่แล้ว

    amazingly explained

    • @quinston
      @quinston  5 ปีที่แล้ว

      Thanks. :)

  • @mrblacksanta
    @mrblacksanta 4 ปีที่แล้ว

    Damn , never expected someone to explain Manacher's algorithm this bad.

  • @harshagrawal3620
    @harshagrawal3620 6 ปีที่แล้ว

    very well explained, nice job dude!!!!

  • @karamveersingh9929
    @karamveersingh9929 4 ปีที่แล้ว

    I don't know why this video has so many dislikes, but probably the best video that explain this algo. thanks Bro

  • @mirela9974
    @mirela9974 5 ปีที่แล้ว

    I really understood the alrogithm. Great! Keep up the great work

  • @kaustubhparmar4274
    @kaustubhparmar4274 5 ปีที่แล้ว

    Really great explanation,finally one -simple and clear.