Find Kth Ancestor Of The given Node In Binary Tree

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

КОМЕНТАРІ • 15

  • @yashpratapsingh2485
    @yashpratapsingh2485 2 роки тому +3

    Best solution till now present on youtube

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

    Well, we are not avoiding recursion when the node is found isnt it?
    For example: getKthAncestor( root, 7, 1); will still undergo recursion for 2->right because 4 is returning NULL to 2, right?

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

      I think removing the "return NULL;" when "k==0" should do the trick?

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

    Correction I think we are not the value 7 actually we are returning the Node which contains value 7 i Know for some this might be same thing but for beginners it can get a little bit confusing

  • @anujmishra778
    @anujmishra778 2 роки тому

    very nice and , very clear explanation sir thank you

    • @CppNuts
      @CppNuts  2 роки тому

      Thanks and welcome

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

    Good Solution...

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

    Nice Explanation 😊

    • @CppNuts
      @CppNuts  10 місяців тому

      Glad you liked it

  • @abhisheksrivastava3699
    @abhisheksrivastava3699 2 роки тому

    Got confused returning root at line 26 will work I was in an impression it may give false alarm to parent cl that we found the target

  • @prateekshrivastava2802
    @prateekshrivastava2802 6 місяців тому +1

    thanks!!!!!

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

    Hi cpp nuts
    Is there any other way to become a patreon because my card was disabled for international transactions if you have any other way pls tell me I have also contacted my bank 🏦 they need more than a month .

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

      Thanks for the consideration, but no man i don't know any other way..

    • @ramakrishna4092
      @ramakrishna4092 2 роки тому +2

      @@CppNuts ok sir thanks