Palindrome Linked List (LeetCode 234) | Full solution with trick | Study Algorithms

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 35

  • @dupladupa-gl8lo
    @dupladupa-gl8lo 3 місяці тому +3

    bro trust me u r a god level teacher bro omg

  • @sameerkumarsingh8942
    @sameerkumarsingh8942 Рік тому +2

    i dont but i get a lot of clarity from your videos , Thanks a lot

  • @hunorvadasz-perhat6001
    @hunorvadasz-perhat6001 Рік тому +4

    Good explanation! Thank you for the great video 😃

    • @nikoo28
      @nikoo28  Рік тому +1

      thank you for subscribing.. :)

  • @poojakasar4572
    @poojakasar4572 Рік тому +4

    explanation is awesome💥💥👍

  • @matthewzarate8851
    @matthewzarate8851 6 місяців тому

    Loved the explanation for both implementations! Thanks Nikhil!

  • @bhumikabansal6022
    @bhumikabansal6022 Рік тому

    your all explanations are awesome

    • @nikoo28
      @nikoo28  Рік тому

      Thank you so much 😀

  • @HemaSanthoshiAkula
    @HemaSanthoshiAkula Рік тому

    such a clean explanation, i loved it

  • @infinite639
    @infinite639 2 роки тому +1

    Why not using collection linkedlist of java
    Why we are making our own linkedlist ?
    Why we are making our own tree?
    Please answer

  • @honey-xr5kp
    @honey-xr5kp 9 місяців тому

    Love your videos! Very well explained. When I tried this code though, I received a time limit exceeded error. I'm sure its on my end, but I'm not sure why because as far as I know its the same code and should work.

    • @nikoo28
      @nikoo28  9 місяців тому

      try the code available on github (link in description)

  • @shubhamgupta8248
    @shubhamgupta8248 Рік тому +2

    Not able to understand why i am getting an error when i write
    while(fast!=null)
    {
    if(fast.val!=slow.val)
    {
    return false;
    }

    • @nikoo28
      @nikoo28  Рік тому

      compare to the code I have

    • @naruto_6663
      @naruto_6663 10 місяців тому +1

      so if this answer matters
      if we write fast != null we will see we have not breaked the linked list in two there is still connection between the 7->2 so that will not be null thats why we write slow != null as slow pointer will point to null 7->null (after the reverse of the list):)

  • @Hello-l3i
    @Hello-l3i 2 місяці тому

    i am not getting ,what if the no.of nodes is odd ???pls explain

  • @deeptigarg799
    @deeptigarg799 9 місяців тому

    When we are doing fast = head and traversed fast to null then why head is not null. Aren't we dealing with the address?

  • @AdityaKumar-yu2br
    @AdityaKumar-yu2br 6 днів тому

    Your first approach doesn't work in case of 121 or 23732 . Correct me if I am wrong ?

  • @121sarthkumar4
    @121sarthkumar4 7 місяців тому

    when we do fast= head does it start from for head of ex 237732 this value or is it half

    • @nikoo28
      @nikoo28  6 місяців тому

      Can you please elaborate on your example?

  • @bhavishyathota6160
    @bhavishyathota6160 4 місяці тому

    ok,but what's in case of linkedlist of odd length?

    • @nikoo28
      @nikoo28  4 місяці тому +1

      The middle element does not matter.
      1 4 x 4 1
      The middle element x could be anything

  • @AlgoXperience
    @AlgoXperience Рік тому +1

    i love it

  • @indrajith2002
    @indrajith2002 11 місяців тому

    bro but for odd testcase it doesnt work .lets say we have a testcase 1->2->3->2->1->null according to you slow points to middle 3 ,
    now if we reverse it will become 1->2->3->null ,where fast points to starting 1 .now if start comparing values @ fast and slow
    upto 2 it will be same after that slow points to 3 but fast points to null .so what to do?

    • @nikoo28
      @nikoo28  11 місяців тому

      It does work, did you try with such a case?

  • @appikeeru5785
    @appikeeru5785 5 місяців тому +1

    Y in his videos very less viewers😢

  • @padmajab2294
    @padmajab2294 Рік тому

    Nice explanation

  • @alihaiderzada423
    @alihaiderzada423 Рік тому +3

    The stack solution does not work if the pattern is 2 - 3 - 7 - 3 - 2. even tho it is a palindrome

    • @bhumikabansal6022
      @bhumikabansal6022 Рік тому +1

      go with the optimized one

    • @SaumyaSharma007
      @SaumyaSharma007 Рік тому +2

      Hello, what you can do:
      Traverse entire L. List. (Let Length of LList come out be n)
      Just push n/2 elements in the stack.
      Now you can check if n is odd which is your case. Curr will be pointing to -7.
      So Curr = Curr-> next;
      Now start comparing left-out L list with stack elements.
      If n was even. Eg 2 -3 -3 2
      Then We would have done nothing. Coz We have already pushed n/2 elements. And Curr will be pointing to the Third element. Now start comparing left-out L list with stack elements.
      Hope it helps. 😄

    • @alihaiderzada423
      @alihaiderzada423 Рік тому

      @@SaumyaSharma007 awesome thanks buddy i will give it ago.. :)

  • @cautioni
    @cautioni 8 місяців тому

    please do a longest palindrome in a linked list

    • @nikoo28
      @nikoo28  7 місяців тому

      Will add it to my pipeline of video

  • @rezowanamehjabinlorel1428
    @rezowanamehjabinlorel1428 9 місяців тому

    Please make more explanation videos

    • @nikoo28
      @nikoo28  9 місяців тому +1

      Will do..new video every week 😄
      Please share as much possible too 😎