Same Tree

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

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

  • @KevinNaughtonJr
    @KevinNaughtonJr  5 лет назад +21

    11 DAYS TILL GAME OF THRONES IF YOU DON'T WATCH EITHER START OR LOSE MY NUMBER

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

      flopped
      hahhahahhah

  • @aydasu
    @aydasu 5 лет назад +17

    Kevin, this is no joke, but found your channel at a time that i needed to sharpen my interview skills so bad and have been following you for a while now. I honestly could not have been so disciplined on leetcode if i did not find your channel. I always try to drop a comment but this time wanted to truly thank you.

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +4

      Thank you so much that means so much to me I really appreciate it! Stick with it it'll pay off in the end!!!

  • @salonigupta1175
    @salonigupta1175 5 лет назад +3

    I just love the background music and the styling of your videos. great job!

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +2

      Thanks so much Saloni I really appreciate the support!!!

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

    This was so enlightening. When you were explaining the base case, recursion suddenly clicked! Thanks Kevin!

  • @MrsMalinaM
    @MrsMalinaM 5 лет назад +2

    I have a phone google interview in an hour and I wish I found your channel a few months ago... Thank you for this awesome content. You are the best at explaining concepts! You make it look very easy:)

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +5

      Thanks so much Marina and best of luck on your phone screen! Let me know how it goes! A couple last minute tips if you’re interested...
      1. Don’t do anything until you understand the problem entirely!
      2. Ask clarifying questions - companies want to see you think before you code and think about edge cases!
      3. Once you finish writing you code don’t assume it’s right! Run a couple test cases on it if possible as well as talk through the logic of your code line by line out loud (it’s like proof reading an essay, if there’s a mistake chances are you’ll catch it while reading out loud)
      4. Be confident you can do this!!!!

    • @thecheekychinaman6713
      @thecheekychinaman6713 5 лет назад +1

      @@KevinNaughtonJr The fact that you take the time to reply to these comments made me subscribe. New to this myself, in a way it kind of feels like doing your SATs, in that you try to recognize the type of problem, and apply a solution.

  • @thecheekychinaman6713
    @thecheekychinaman6713 5 лет назад +1

    Had this asked in an interview just now. A variation about similarity (nodes can be swapped). Forgot to code in the half-swapped cases, but thats life! Thanks Kevin!

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

    thank you for your clear walk throughs on these challenges. great help!

  • @yicai7
    @yicai7 5 лет назад

    Thanks Dude!
    Still remember the scenario that "Recursion just like you are watching a movie in the cinema "

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

    Keep up the good work ma man, you helping a lot of us out here ✌

  • @binbinzhou
    @binbinzhou 5 лет назад +4

    Love the reference to StackOverflow w/ logo!

  • @HARIHaran-ks7wp
    @HARIHaran-ks7wp 3 года назад

    The Game of Thrones excitement didn't age well 😂😂😂

  • @ganeshbirajdar4382
    @ganeshbirajdar4382 2 года назад

    Thanks for the video. Helpful 👍

  • @Randomisticful
    @Randomisticful 2 года назад

    Hate these kinds of problems from the bottom of my heart. Don't even have a motivation to read the problem when I see Node, List etc.

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

    your channel is dope brother, thanks a lot

  • @kalyanimeshram7669
    @kalyanimeshram7669 2 года назад

    simple and understandable , thanks.

  • @anthonycheng12
    @anthonycheng12 5 лет назад +10

    Hey Kevin love the videos can you do more leetcode mediums I feel like in interviews I never encounter easy problems it’s always mediums

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +1

      Hey Anthony thanks so much and you've got it!!!

  • @saloneerege2006
    @saloneerege2006 5 лет назад +11

    Only if I could solve problems during an interview this easily. So difficult to remain calm during an interview
    :-(

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +2

      It's tough Salonee, don't beat yourself up, just keep practicing! :)

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

    I like ur presentation skills ,simply superb keep rocking

  • @nealpatel7696
    @nealpatel7696 5 лет назад +1

    So glad you mentioned runtime. I actually followed the solution this time haha.

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад

      Haha I FINALLY remembered!!! Awesome I'm happy to hear the solution made sense :)

    • @nealpatel7696
      @nealpatel7696 5 лет назад

      @@KevinNaughtonJr I actually had a question to ask! I recently came across it in a coding challenge. If we're given an array where each item in the array is a fountain and max a fountain can spray (its range) is min(i + a[i], n) where n is the length of the array, what is the minimum number of fountains needed to be turned on to cover the entire array? An example is [1, 1, 1, 2, 3, 1, 1, 1], n = 8 and the answer would be one since the 4th index i = 3 would give 3 + 2 = 5 and 5 on each side would cover the entire array. I have no clue on how to approach this and have been racking my brain. I know it requires a dp solution as it's very similar to the tower hop problem or the min number of jumps problem.

  • @mokoboko2482
    @mokoboko2482 Год назад

    who was google asking same tree to? the service dogs ??

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

    Please make more videos on Dynamic Programming !

  • @Garensonic
    @Garensonic 5 лет назад +3

    Tree problems we're what stumped me during my Amazon interview a few months ago (can't give the exact problems due to NDA)

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

    Trees solutions with recursion are pretty trivial, we should concentrate more using Stacks or Queues for solving the tree problems, and that's what the interviewer expects. Gave an onsite interview with one of the BIG 5 and first thing the interviewer tells you with tree problems is "No Recursive Solution Please !". Please don't block me. :)

  • @FrankLi92
    @FrankLi92 5 лет назад

    Hey Kevin, can you do "All Possible Full Binary Trees" on LC when you get a chance? There aren't many good solutions on LC and no one really has done a video on this problem before. It's an interesting problem, but I can't grasp the concept because it's recursive heavy and I think has some DP mixed in?

  • @surekhak3874
    @surekhak3874 5 лет назад +1

    Hi, Thank you for your videos. It's been extremely helpful. Can you please make an video on Lettcode#498. Diagonal traversal.

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад

      Anytime and thanks for the suggestion I'll see what I can do!

  • @justinf7438
    @justinf7438 5 лет назад

    Nice Video, What made you choose software engineering as your career path?

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад +1

      Thanks Spark! I just liked video games when I was younger so I was interested in programming so I gave it a shot in college and loved it

  • @hozher
    @hozher 5 лет назад

    How many tries did you do?

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

    Thanks

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

    What is the space complexity for this recursion method?

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

    Kevin , i want is to give me exemple of param TreeNode p and q to pass it through isSameTree(p, q) function to excute it in other IDE THanks

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

    You make it super easy..❤️

  • @ZenNoah
    @ZenNoah 5 лет назад

    Good shit bro, have a coding challenge to do from Google, hope it's not too bad

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад

      Thanks man really appreciate it! Good luck and lmk if there's anything I can do to help you prepare, you got this!!!

  • @Garensonic
    @Garensonic 5 лет назад

    Also do you know if there is an iterative solution to this problem

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 лет назад

      You can always write thing iteratively or recursively!

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

    U r GOD!

  • @AmanMishra-im6sh
    @AmanMishra-im6sh 4 года назад

    Fabb...

  • @dev-skills
    @dev-skills 3 года назад

    Same logic could be simply more compactly written as below
    ```
    public boolean isSameTree(TreeNode p, TreeNode q) {
    if ((p == null) && (q == null)) return true;
    if ((p == null) || (q == null)) return false;
    return (p.val != q.val) ? false : isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
    ```

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

    do more problems on graphs and bit manipulation , i have learnt the implementation concept of trees from your videos only

  • @justinrblx9844
    @justinrblx9844 5 лет назад

    Hello! My dream is to become a software engineer in the future.

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

    Nice use of else if for implementing logic

  • @kumaransg1828
    @kumaransg1828 5 лет назад

    Wrong link to problem, fix it kevin