Thanks for this video, very insightful breakdown of the question.
@leeroymlg46929 ай бұрын
Hello everyone welcome back and let's write some more neetcode today
@crackfaang9 ай бұрын
Noooooooo 🙅♂️🙅♂️
@antoinenijhuis45010 ай бұрын
For a CS Graduate that is not very strong in projects resumé but loves grinding leetcode. Should I focus on projects first before getting into Leetcode 150? Or do you reckon it is useful for me to grind these kind of problems without much programming experience?
@jaredtewodros Жыл бұрын
How can you implement this solution without the global min variable?
@LawAssistantAI6 ай бұрын
n this particular scenario, if we find a leaf node, we could technically stop searching further because we already have a minimum depth candidate. This approach is especially useful in the context of finding the minimum depth of a binary tree. Instead of searching all the nodes unnecessarily, we can stop the search early when we find the first leaf node at the current minimum depth. This would prevent us having to continue to traverse, wouldnt it?
@Tallonest2 ай бұрын
No, because what if you start at the root and find a leaf node on the left subtree 3 down? If you explore the right subtree next, what if you find it’s 1 down? So you actually need to keep going
@vabhs1920038 ай бұрын
Wouldn't the following test case fail for the empty tree such as [], since the default value is set as float('int') while the value returned should be 0?
@ilhomsadriddinov3627 Жыл бұрын
Why didn’t you use bfs approach which is slightly better for average cases. I mean traversing the tree by level.
@crackfaang Жыл бұрын
In retrospect I should have used BFS because you can theoretically stop early but in the case of an extremely skewed tree, the overall time complexity is the same. We only care about worst case runtime complexity when doing the analysis so both are fine. You could mention the average case thing for some bonus points but either answer works here as they are the same overall time/space complexity
@moezzzz9341 Жыл бұрын
one thing im confused is how you have access to minDepth in your dfs method which is defined in the original method? Is it because you are attaching self to the front of it so both methods have access to that variable?
@versace10 Жыл бұрын
hes not calling the method he created a min_depth variable which hes using
@rishikaverma9846 Жыл бұрын
ValueError: could not convert string to float: 'int' self.min_depth = float('int') Line 11 in minDepth (Solution.py) ret = Solution().minDepth(param_1) Line 38 in _driver (Solution.py) _driver() Line 49 in (Solution.py) the same code shows this error. can you please tell me how to solve it?
@crackfaang Жыл бұрын
It’s float(‘inf’) not ‘int’. You spelled it wrong 😉