Sum of Left Leaves

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

КОМЕНТАРІ • 27

  • @KevinNaughtonJr
    @KevinNaughtonJr  6 років тому +3

    My interviews repo on GitHub in case you guys don't know about it! github.com/kdn251/interviews

  • @josepchwill1304
    @josepchwill1304 4 роки тому +2

    These videos definitely are helpful, when I was working on my undergrad, they didn't really do that great of a job with algorithms, so I am trying to understand them a lot better now.

    • @KevinNaughtonJr
      @KevinNaughtonJr  4 роки тому

      Josepch Will thanks! If you need help understand and learning these questions be sure to sign up for the interviewing service I created thedailybyte.dev/?ref=kevin I recommend joining the annual plan if you can!

  • @abhishekbisherwal6856
    @abhishekbisherwal6856 4 роки тому +1

    Man You are great i was struggling to approach an exact solution, but just listening to your explanation of the problem only i was able to code it myself and submitted it. Great work .

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

    This was really helpful! Thank you so much!

  • @Justinkol
    @Justinkol 6 років тому +1

    Great! Keep these up! Found your channel through your interviews github repo.

    • @KevinNaughtonJr
      @KevinNaughtonJr  6 років тому +1

      Thanks Justin I hope you're finding this channel and the repo helpful!

  • @vishaakravi6249
    @vishaakravi6249 5 років тому +6

    Hey I was wondering for tree problems how I know if I need a helper function for my recursive calls and how I know what I should pass in as parameters. Sometimes we can just use the given function to solve the problem and sometimes we need a helper. Is there a guideline that can help with this?

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 років тому +7

      Great question! It really depends on parameters you need to pass to the function and what the function needs to remember...for example if it needs to remember or add something to a previous result, you might have to make a helper function that takes an array of number (because the array will be the same for all of the recursive calls since it's passed by reference, not value). LMK if that makes sense, if it doesn't I'm happy to explain further :)

    • @algorithmsguide5076
      @algorithmsguide5076 5 років тому

      @@KevinNaughtonJr Perfect Explanation !!

  • @janmichaelaustria620
    @janmichaelaustria620 4 роки тому +1

    nice vid! thanks for the explanation Kevin. super solid!

    • @KevinNaughtonJr
      @KevinNaughtonJr  4 роки тому +2

      Jan Michael Austria thanks and anytime! If you need help with these kinds of questions and like my explanations check out the interviewing service I created thedailybyte.dev/?ref=kevin I’d recommend joining the annual plan if you can!

  • @c_uludag
    @c_uludag 5 років тому +2

    Another solution could be:
    class Solution {
    int sum = 0;
    public int sumOfLeftLeaves(TreeNode root) {
    traverse(root, false);
    return sum;
    }
    private void traverse(TreeNode node, boolean isLeft) {
    if (node == null)
    return;
    traverse(node.left, true);
    if (isLeft && node.left == null && node.right == null)
    sum += node.val;
    traverse(node.right, false);
    }
    }

    • @vardhamankothari3450
      @vardhamankothari3450 4 роки тому

      I approached this problem using the same way you mentioned... Kinda looks more cleaner

  • @code7434
    @code7434 4 роки тому +2

    Cool ,please take harder tree problems.Also please if we have very strong command on data structures then its sufficient for companies?

  • @venkatsai5013
    @venkatsai5013 6 років тому +1

    Awesome work, would you help me personally I have few doubts

  • @code7434
    @code7434 4 роки тому

    Kindly make a playlist on Microsoft

  • @ItsDavidT
    @ItsDavidT 6 років тому +1

    Great content! Subbed! :D
    What would be the time complexity of this solution?

    • @KevinNaughtonJr
      @KevinNaughtonJr  6 років тому +2

      Thanks David and happy to hear it! The time complexity is O(n) where n is the number of nodes in the tree!

  • @vk1618
    @vk1618 4 роки тому

    Such concise logic for a dp. #review

  • @pulkitk3388
    @pulkitk3388 5 років тому +1

    Bro u always solve questions labelled easy in this video seriesWhy don't have a mix of some good medium questions as well

  • @Porsche911Dream
    @Porsche911Dream 4 роки тому

    You're great!!!!

  • @pushkarraj3839
    @pushkarraj3839 5 років тому

    hey Kevin can you please help us understand Task Schduler question . Leet code 621.

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 років тому +1

      Definitely, I'll see if I can make a video on that one next week thanks for the suggestion!

  • @ayshalak
    @ayshalak 6 років тому

    easy peasy - but great content