LeetCode 104. Maximum Depth of Binary Tree - Interview Prep Ep 65

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 33

  • @slycreator
    @slycreator 2 года назад +3

    Actually this is the best explanation you can find on youtube....Others just focused on writing the code.Thanks man!

  • @TejaswiniManjunatha
    @TejaswiniManjunatha 3 года назад +5

    Thanks for explaining this so well. I feel like a lot of coding youtubers don't break down a problem into it's visual side which is so important for learning how something works!

  • @deeps-n5y
    @deeps-n5y 10 месяцев назад +1

    Best visualization out there. Thanks

  • @cameronhoward24
    @cameronhoward24 3 года назад +1

    This was the best explanation I could find of this problem, I appreciate you drawing out the recursive calls.

  • @letsplay1097
    @letsplay1097 Год назад +1

    best video so far

  • @yixuanniu5482
    @yixuanniu5482 Год назад +1

    Thank you, I was looking for exactly this type of diagrammatic explanation! Thank you so much!!!

  • @Patiencelad
    @Patiencelad 3 года назад +2

    Excellent explanation. Thank you! Keep up the good work!

  • @mcreyfonacier1982
    @mcreyfonacier1982 4 года назад +3

    Level up! My algorithmic intelligence has been increased by 3.

  • @adithyagowda4642
    @adithyagowda4642 4 года назад +2

    That was the best explanation I've ever seen. Thank you very much!

  • @ILoveChocx3
    @ILoveChocx3 4 года назад +3

    hey, thanks for the great explanation and effort Fisher. I hope you could possibly show a visual explanation for the iterative step as well for those who are not familiar with the LinkedList data structure. Thank you!

    • @FisherCoder
      @FisherCoder  4 года назад

      Great suggestion!

    • @yynnooot
      @yynnooot 3 года назад

      Yeah, I came here for the visual explanation for the iterative approach :(

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd 5 лет назад +5

    Thanks for such a detailed explanation,quite informative video.Please also explain code using C++.Please

  • @qahoushh
    @qahoushh 3 года назад +1

    you are amazing man , love your videos

  • @rakshith3547
    @rakshith3547 4 года назад +2

    I finally understood recursion , thanks buddy

  • @kaanhanokyay463
    @kaanhanokyay463 3 года назад +1

    that's a great explanation. Thanks !!

  • @tuozhang4969
    @tuozhang4969 4 года назад +1

    Excellent explanation. Much appreciated!

  • @yunlongjia5380
    @yunlongjia5380 3 года назад +1

    Always the best! Thanks man!

  • @lakshaygupta9229
    @lakshaygupta9229 3 года назад

    Hey, I'm having trouble
    I wrote the following code but not sure why it returns the wrong answer
    public int maxDepth(TreeNode root)
    {
    if(root==null) return 0;

    if(root.left!=null) lh = maxDepth(root.left);
    if(root.right!=null) rh = maxDepth(root.right);

    return 1+Math.max(lh,rh);

    }

    • @sajramkisho9991
      @sajramkisho9991 3 года назад

      public int maxDepth(TreeNode root)
      {
      if(root==null) return 0;

      int lh = maxDepth(root.left);
      int rh = maxDepth(root.right);

      return 1+Math.max(lh,rh);

      }

  • @donkeykong5616
    @donkeykong5616 2 года назад +1

    nice!

  • @zhenliu4779
    @zhenliu4779 4 года назад

    pretty good. BTW, I guess you can speak mandarin, right?

  • @hydrocy.9165
    @hydrocy.9165 7 месяцев назад

    int maxDepth(TreeNode* root) {
    int maxDepth = 0; // Initialize the maximum depth
    int count = 0; // Initialize the current depth counter
    dfs(root, count, maxDepth);
    return maxDepth;
    }
    private:
    void dfs(TreeNode* node, int count, int &maxDepth) {
    if (node == NULL) return;
    count++; // Increment counter to reflect current depth
    if (count > maxDepth) {
    maxDepth = count; // Update maximum depth
    }
    dfs(node->left, count, maxDepth);
    dfs(node->right, count, maxDepth);
    }
    }; brother this code works but i cant understand how every recursion call maintain its own count variable