Hey Neetcode, Whenever you get some free time can you please solve the problem - Number of Wonderful Substrings. I haven't been able to find a single good video explaining the intuition of how to solve such problems. Thank you in advance! 😃
You didn't really need a hashmap even if using it doesn't hurt performance much I suppose, I avoided it doing the following: Whenever I encounter a leaf node, I pop again, if what I just popped isn't leaf, I add the previous leaf and and then add the non leaf, if both nodes are leaf, I pop the operator again and evaluate both of them and append the result. If this wasn't a tree and was some sort of a graph then yes a hashmap would be useful to not evaluate a node multiple times( number of times it's referenced)
My friend, I want to examine your brain. After so many leetcode questions, I think you have an extremely superior brain.
Hey Neetcode, Whenever you get some free time can you please solve the problem - Number of Wonderful Substrings. I haven't been able to find a single good video explaining the intuition of how to solve such problems. Thank you in advance! 😃
Shoutout to laddoo gang.
Video was helpful as ever, thank you neetcode for the neat code.
Thanks for keep posting the solutions of the daily challenges! It's helping me a lot this past few days!
I think the recursive solution is O(log n) as it's a full binary tree
I solved it iteratively using 2 stacks for simplicity
Never this early, hello neetcode 😊🎉
You didn't really need a hashmap even if using it doesn't hurt performance much I suppose, I avoided it doing the following:
Whenever I encounter a leaf node, I pop again, if what I just popped isn't leaf, I add the previous leaf and and then add the non leaf, if both nodes are leaf, I pop the operator again and evaluate both of them and append the result. If this wasn't a tree and was some sort of a graph then yes a hashmap would be useful to not evaluate a node multiple times( number of times it's referenced)
The iterative approach is medium if not quite hard
Which laddoo do you like bro?
2055. Plates Between Candles... Next Please..
the iterative solution is just as efficient as the recursive one right ?
yeah thats right
LADDOO REFERENCE AGAIN!
🥹🟠
Ladooo 😂