988. Smallest String Starting From Leaf | Tree | DFS | Recursion & Backtracking | Divide & Conquer
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
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
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.
Thanks Aryan i was very Confused About TC but you cleared it very well. Probably the best explanation out there on internet
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.
Amazing You deserve my like and Sub
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
thanks for the summary.. And kudos to Aryan for such consistency with great explanation
kaisi jeeb laplapai
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đą.
not my white thing đđ
Well Explained brother! Hats off to your effort!
bro u explained very well
Thanks, Aryan
thanks for the worst case time and space complexity thing
05:34 đ€Ł
apart from your english loved the video and in dept explanation of solution
5:36 đ
BTW don't eat center fruit gum, cause well you know.
bruh, reversing also taking o(n) right ?
sorry u later took that part, my badđ