Thank you soo much for making these video and soo early as well!!!
@tommyshelby62777 ай бұрын
bro sneaked in `ladoos` and thought we wouldn't notice😂?
@weens5717 ай бұрын
Just when I needed the video. Thanks. 😁
@HimanshuSaini-ur6by7 ай бұрын
This was great..by 9 minute mark I got an idea and coded it out. it workedd
@АлекСневар7 ай бұрын
Actually, the second solution with one variable is much easier to understand imho.
@aashishbathe7 ай бұрын
LADDOOO AGAINNN. Just remembering that, I just had it yesterday and it was great!
@shashwatsingh92477 ай бұрын
Tough ques. thanks neetcode
@MP-ny3ep7 ай бұрын
Great explanation as always. Thank you
@kwakukusi40947 ай бұрын
best explanation
@chien-yuyeh93867 ай бұрын
Thanks for sharing 🎉
@pastori26727 ай бұрын
i actually struggled so much on this one and i thought your gonna clown them for the difficulty again but i guess not
@vedantjha23277 ай бұрын
Interesting question.
@realisticlevel25532 ай бұрын
harddd to come up with this I came up with the intuition of the +1 and -1 for when passing up coins and "asking" for coins, and I was trying to balance it with the current level of the tree :(
@nikolatesla3992 ай бұрын
class Solution: res = 0 def distributeCoins(self, root: Optional[TreeNode]) -> int: self.helper(root) # Retrieve the result and reset `Solution.res` for future calls ans = Solution.res Solution.res = 0 return ans def helper(self, root: Optional[TreeNode]) -> int: if not root: return 0 # Calculate excess coins for left and right children left = self.helper(root.left) right = self.helper(root.right) # Total moves required to balance current node Solution.res += abs(left) + abs(right) # Return net balance of coins after balancing current node return left + right + root.val - 1
@vikneshcs18 күн бұрын
Can I convert it to graph and do bfs on node 0
@shivangikhemka43797 ай бұрын
Hey, How would be solve this to get minimum number of moves if we had more total coins than number of total nodes? total coins > total nodes (Extended problem)
@priyanshagarwal84907 ай бұрын
2055. Plates Between Candles... Next Please..🙏
@sivaramakrishnankn17217 ай бұрын
boondhi laddoo gang represent
@kevinwang86327 ай бұрын
this one was hard
@nikitathacker50966 ай бұрын
How can we conclude that this question doesnt require DP? At first glance, we have choices and we need minimum, making it a good candidate for DP
@impolitebigmac30447 ай бұрын
I hate leetcode
@staywithmeforever7 ай бұрын
Double bfs?
@ksvijayan067 ай бұрын
public int[] dfs(TreeNode root){ if(root == null) return new int[]{0,0}; //size, coins int[] left = dfs(root.left); int[] right = dfs(root.right); int[] curr = new int[]{left[0]+right[0]+1, left[1]+right[1]+root.val}; res += Math.abs(curr[0] - curr[1]); return curr; } java code
@sajankumarrajbanshi11587 ай бұрын
i love ladoos
@Masterasadumar7 ай бұрын
lol ladu
@sankhadip_roy7 ай бұрын
extra = left_extra+right_extra+1-node.val # calculated it from the first solution equations extra = left_extra+right_extra-1+node.val # provided by neetcode both is working don't know how