Same Tree

แชร์
ฝัง

ความคิดเห็น • 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!!!

  • @janmichaelaustria620
    @janmichaelaustria620 4 ปีที่แล้ว +1

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

  • @mashak3765
    @mashak3765 3 ปีที่แล้ว

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

  • @thecheekychinaman6713
    @thecheekychinaman6713 4 ปีที่แล้ว +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!

  • @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!!!

  • @arafatkhan5489
    @arafatkhan5489 3 ปีที่แล้ว

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

  • @MrsMalinaM
    @MrsMalinaM 4 ปีที่แล้ว +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  4 ปีที่แล้ว +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 4 ปีที่แล้ว +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.

  • @yicai7
    @yicai7 4 ปีที่แล้ว

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

  • @ganeshbirajdar4382
    @ganeshbirajdar4382 2 ปีที่แล้ว

    Thanks for the video. Helpful 👍

  • @nedwilliams8806
    @nedwilliams8806 3 ปีที่แล้ว

    your channel is dope brother, thanks a lot

  • @kalyanimeshram7669
    @kalyanimeshram7669 2 ปีที่แล้ว

    simple and understandable , thanks.

  • @bokams3385
    @bokams3385 4 ปีที่แล้ว

    I like ur presentation skills ,simply superb keep rocking

  • @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! :)

  • @binbinzhou
    @binbinzhou 5 ปีที่แล้ว +4

    Love the reference to StackOverflow w/ logo!

  • @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.

  • @nknidhi321
    @nknidhi321 3 ปีที่แล้ว

    You make it super easy..❤️

  • @HARIHaran-ks7wp
    @HARIHaran-ks7wp 3 ปีที่แล้ว

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

  • @karlwhitford7523
    @karlwhitford7523 2 ปีที่แล้ว

    Thanks

  • @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.

  • @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)

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 ปีที่แล้ว

      No worries and yeah tree problems are tough

  • @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!!!

  • @thetechthirsty713
    @thetechthirsty713 4 ปีที่แล้ว

    U r GOD!

  • @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!

  • @AmanMishra-im6sh
    @AmanMishra-im6sh 3 ปีที่แล้ว

    Fabb...

  • @dumbfailurekms
    @dumbfailurekms ปีที่แล้ว

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

  • @rajasanchit
    @rajasanchit 4 ปีที่แล้ว

    What is the space complexity for this recursion method?

  • @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?

  • @hozher
    @hozher 5 ปีที่แล้ว

    How many tries did you 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

  • @rahmabader1627
    @rahmabader1627 3 ปีที่แล้ว

    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

  • @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!!!

  • @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. :)

  • @vk1618
    @vk1618 4 ปีที่แล้ว

    Nice use of else if for implementing logic

  • @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!

  • @dineshkoya2291
    @dineshkoya2291 3 ปีที่แล้ว

    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.

  • @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);
    }
    ```

  • @kumaransg1828
    @kumaransg1828 5 ปีที่แล้ว

    Wrong link to problem, fix it kevin

    • @KevinNaughtonJr
      @KevinNaughtonJr  5 ปีที่แล้ว

      just updated thanks for letting me know