FIND DUPLICATE SUBTREES | LEETCODE # 652 | PYTHON DFS SOLUTION

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • In this video we are solving a popular Google & Amazon interview question that is a classic DFS question: Find Duplicate Subtrees (Leetcode # 652).
    This is yet another DFS based tree question that follows the same tried-and-tested approach that we use for so many questions on this channel.

КОМЕНТАРІ • 26

  • @mohsenvazirizade6334
    @mohsenvazirizade6334 Рік тому +2

    Thank you for the solution. I think this approach is O(N**2) due to line 11. Also, there is no point in having path as an input argument to the function.

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

    Excellent video again! Please do videos on all neetcode 150, your concise , clear explanations are appreciated and needed ! Thank you so much!

    • @crackfaang
      @crackfaang  7 місяців тому +1

      Why would I make videos for someone else's list. I already put out a spreadsheet with problems for people to learn LC that relies more on chains of similar problems such that you can solve questions that are similar in nature: learning patterns and being able to apply previous knowledge to new questions

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

      @@crackfaang or complete the blind 75? Your efforts are appreciated btw , no hard feelings

    • @crackfaang
      @crackfaang  7 місяців тому +1

      ​@@dnm9931All good, I know you didn't mean anything malicious by it. I personally don't see the point of those lists because they give you a false sense of hope that solving X questions == ready to ace Google interview.
      That simply isn't the case and if anything they are only useful for just getting a basic breadth first knowledge base

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

      @@crackfaang then how would you recommend is the best way to prepare for a faang interview? Or is a majority of it luck?

    • @crackfaang
      @crackfaang  7 місяців тому +1

      ​@@dnm9931Video coming out on this soon. But yes lots of memorization + luck on the day that you get a question you've seen before

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

    you're close to 1000 man, keep it up!!

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

    I dont understand the need to pass path as a parameter, it works without it

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

    the thumbnail game is getting even better!!

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

    Thanks

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

    Thank you. keep posting!

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

    The audio in your videos is very low ,I think increasing it,it will be more helpful

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

      Hmm you aren’t the first person to mention this. I speak directly into the mic so not sure what’s up. Maybe I can tweak my audio settings when rendering the video. Thanks for the heads up

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

      @@crackfaang I think maybe a better microphone is needed, your content is really good and the only thing I think that is holding to blow this channel up is the sound issue, hope you will fix it soon 😄😄

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

    thank you!!! well explanation

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

    why is the comma needed in the join? it doesn't pass a test case with out it

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

      coz there may be several numbers going one by one

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

    Is the time complexity ON, Are you sure?

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

      I do believe the time complexity of your solution is ON², cuz, there are N² subtree, every subtree need to be compare by the hashmap. correct me , if I'm wrong. thank you

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

      And, the space complexity is also N²

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

      @@MeetManga Ur wrong

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

      time is indeed O(N2)

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

      Chatgpt says he’s correct lol