988. Smallest String Starting From Leaf | Tree | DFS | Recursion & Backtracking | Divide & Conquer

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 15. 04. 2024
  • In this video, I'll talk about how to solve Leetcode 988. Smallest String Starting From Leaf | Tree | DFS | Recursion & Backtracking | Divide & Conquer | O(n) time ?
    Let's Connect:
    đŸ“±Discord (Join Community) : / discord
    📝Linkedin: / aryan-mittal-0077
    📾 Instagram: / ez.pz.dsa
    đŸ’» Twitter - / aryan_mittal007
    đŸ€– Github: github.com/aryan-0077
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✹ Hashtags ✹
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáƙe • 22

  • @ARYANMITTAL
    @ARYANMITTAL  Pƙed 3 měsĂ­ci +10

    Please remove your blanket trust from youtubers, always apply your brain too & make sure you learn right things to get your basics strong, else you'll get a dopamine hit of solving a problem which ideally you didn't learn anything from. Adding, whenever i miss any optimal approach, do comment also, that other people watching realise that they are missing something. đŸ€“
    Now if you are afraid of your Jobs, go watch this video❀ - czcams.com/video/yn9jA4P1OWU/video.html

  • @priyanshuawasthi9479
    @priyanshuawasthi9479 Pƙed 3 měsĂ­ci +3

    Bro, You're such a great guy! Now it may seem like you're not getting reach but trust the process. For me you're by far the best DSA guide.

  • @Ashutosh07535
    @Ashutosh07535 Pƙed 3 měsĂ­ci +1

    Thanks Aryan i was very Confused About TC but you cleared it very well. Probably the best explanation out there on internet

  • @Authenticbharatiya
    @Authenticbharatiya Pƙed 3 měsĂ­ci +1

    Sir hat's off to your dedication for making such good videos. Even though i have been doing dsa for 4 months i still get to know the very basic things from you which i can't find anywhere over the internet. Please sir keep on uploading regularly it really helps me a lot and i don't know about others but i am a regular viewer of your channel. Really grateful to you sir for the efforts you put.

  • @-lyxics
    @-lyxics Pƙed 3 měsĂ­ci +2

    Amazing You deserve my like and Sub

  • @zebra-er6xc
    @zebra-er6xc Pƙed 3 měsĂ­ci +9

    learnings:
    // s = s+ ch // takes O(n) time
    // s += ch // takes O(1) time
    // s.push_back(ch) // also takes O(1) time
    // by passing the string as reference we have prevented the copying of string at every stage
    // which will save us space and also time used in copying the string ie O(n)
    // we will have maximum number of leaf nodes in a complete binary tree, 2 nodes at every node
    // maximum number of leaf nodes = N/2 if total number of nodes = N
    // Height of balanced binary tree = log2(N) = length of each string
    // which gives us maximum time complexity
    // worst case time taken to traverse till leaf nodes*time taken to reverse all the strings
    // as O(N/2 * logN + N/2(visiting all nodes) ) = O(N*logN)
    // space = O(logN) // height of binary tree in a balanced tree
    // for worst case space complexity, we will have a skewed tree
    // space complexity = O(N)
    // and for that time complexity will be O(N) since there is only one leaf node
    // and we will reverse the string only once that will be of length N

    • @ok-google-run
      @ok-google-run Pƙed 3 měsĂ­ci

      thanks for the summary.. And kudos to Aryan for such consistency with great explanation

  • @gilfoyle2211
    @gilfoyle2211 Pƙed 3 měsĂ­ci +4

    kaisi jeeb laplapai

  • @rajrajesh1669
    @rajrajesh1669 Pƙed 3 měsĂ­ci +1

    This problem is a decent problem but I messed up a lot handling edge cases😱💯.
    I tried to solve without using global variable and that was the worst decision I made😱.

  • @RohanSharma-tl9wh
    @RohanSharma-tl9wh Pƙed 3 měsĂ­ci +4

    not my white thing 🌚🌚

  • @codingkart245
    @codingkart245 Pƙed 3 měsĂ­ci

    Well Explained brother! Hats off to your effort!

  • @mohdsahil3191
    @mohdsahil3191 Pƙed 3 měsĂ­ci

    bro u explained very well

  • @the_ved11
    @the_ved11 Pƙed 3 měsĂ­ci

    Thanks, Aryan

  • @zebra-er6xc
    @zebra-er6xc Pƙed 3 měsĂ­ci

    thanks for the worst case time and space complexity thing

  • @dhruvrawatt9
    @dhruvrawatt9 Pƙed 3 měsĂ­ci +11

    05:34 đŸ€Ł

  • @atul9203
    @atul9203 Pƙed 3 měsĂ­ci +1

    apart from your english loved the video and in dept explanation of solution

  • @abhinay.k
    @abhinay.k Pƙed 3 měsĂ­ci +1

    5:36 💀

  • @-lyxics
    @-lyxics Pƙed 3 měsĂ­ci

    BTW don't eat center fruit gum, cause well you know.

  • @Owais486
    @Owais486 Pƙed 3 měsĂ­ci

    bruh, reversing also taking o(n) right ?

    • @Owais486
      @Owais486 Pƙed 3 měsĂ­ci

      sorry u later took that part, my badđŸ˜