Thank you brother, And if there is something i can add that would help so much, Learn How To Learn, Check a book and a course with the same name by Barbra Okley And a very small one on Edx called Learn Like A Pro And Trust me, in this world Defuse mode of your brain is your best friend
Initially i tried brute force solution but go TLE in the morning. Later i tried again and again i couldn't got one. I left and came back in afternoon tried again with fresh mindset then after some time i got the first approach using min heap. I thought i optimized but the solution is still not the best solution. Then i came to your video to find the optimized solution. But man how could we get such ideas. Besides nice explanation.
Interesting problem. I've actually had more time for personal projects lately and I guess I forgot I was solving leetcode and trying to optimise for a real world situation where we'll need to make this check multiple times. Here's now I tried to optimise for multiple reads: Seive of eratothenes (lol... ) I figured that as long as I have sufficiently large seive of eratothenes, I could make that sieve just once, take the performance penalty for creating that massive sieve and then going on to be rest assured that every lookup that for the nth ugliest number will take a 0(1) look up since the function that returns the sieve is cached. Of course in a real situation, we'd need to know the limits of n so that we'd know what's the sufficient size of the sieve to solve this problem. I read the editorial and I still needed to watch your video to actually snap out of the production-code-optimisation bubble and context switch to leetcode level problems. Yikes. Another lesson in the bag; " Be kind on yourself and give your brain enough time to rest and gracefully context switch to something you take equally as serious as your job or open source projects " Man, I'm tired😪..... AND MOST IMPORTANTLY, thanks again for all that you do!
in your bruteforce solution , u can also dicard visited set instead take a set and push all the elements into it that way u dont have to keep track of visited elements
NeetCode Medium Question: From starting to till now how many different intro is used by Navdeep if today's intro is "Hey, Everyone welcome back, and lets write some NeetCode". Answer : 2 , As on his first video he can't be saying Welcome Back coz everyone was coming for first time. (I don't know why I commented this...)
For the last solution - how to prove or illustrate that we need just three pointers? I.e.: we created the pointers only for the first ramification. When we get more subtrees, how do we know that we do not need to introduce more pointers to track more "racing" numbers? Why i2, i3, and i5 will always have the current minimum among them?
After looking at the code - I think, a possible explanation can be: all i2, i3, and i5 are moving through ALL numbers calculated one by one, so they will exhaust all options
neetcode stop seshing us, the dp solution is in O(n)! bro what do i do if google asks me to optimize the heap solution - i am cooked (this is half a joke)
dont understand the intuition at all. I mean multiplying 1 by 2,3,5 and then all of the children of one with 2,3,5 makes sense but not sure how I would ve come to the conculsion to use min heaps and use the smallest. Maybe due to the lack of my graph knowledge...
To everyone grinding through LeetCode and questioning if they're good enough when comparing themselves to others' success-don't give up.
💪💪
Thanks😅
Thank you brother,
And if there is something i can add that would help so much,
Learn How To Learn,
Check a book and a course with the same name by Barbra Okley
And a very small one on Edx called Learn Like A Pro
And Trust me,
in this world Defuse mode of your brain is your best friend
me irl
Once you know how to generate these numbers, problem seems trivial. But IDK how to build up the intuition to come up with the solution on my own.
The same problem I have. How do you build up the intuition to come up with how to generate these numbers?
The three pointers solution is so elegant.
but not intutive
Oh man, I thought i was doing okay coming up with that heap solution on my own, but your array solution is seriously next level. 😮
Leetcode is just like Jack Salter in Grand Turismo : "I am here to prove that you can't"
finallyyyyyyyy this problem waited for years for someone to make this one thanks
this problem made me feel ugly
Me too
what the heck was that man. i would have got the array solution even in my whole life
Understood third solution, but I won't code that yet. Remind me to come back later, I will try to come up with that on my own.
Initially i tried brute force solution but go TLE in the morning. Later i tried again and again i couldn't got one. I left and came back in afternoon tried again with fresh mindset then after some time i got the first approach using min heap. I thought i optimized but the solution is still not the best solution. Then i came to your video to find the optimized solution. But man how could we get such ideas.
Besides nice explanation.
Thank you for the great video! The first heap solution makes sense to me. Can you further explain the definition of the three-pointers?
Interesting problem. I've actually had more time for personal projects lately and I guess I forgot I was solving leetcode and trying to optimise for a real world situation where we'll need to make this check multiple times. Here's now I tried to optimise for multiple reads:
Seive of eratothenes (lol... )
I figured that as long as I have sufficiently large seive of eratothenes, I could make that sieve just once, take the performance penalty for creating that massive sieve and then going on to be rest assured that every lookup that for the nth ugliest number will take a 0(1) look up since the function that returns the sieve is cached. Of course in a real situation, we'd need to know the limits of n so that we'd know what's the sufficient size of the sieve to solve this problem.
I read the editorial and I still needed to watch your video to actually snap out of the production-code-optimisation bubble and context switch to leetcode level problems. Yikes. Another lesson in the bag; " Be kind on yourself and give your brain enough time to rest and gracefully context switch to something you take equally as serious as your job or open source projects "
Man, I'm tired😪.....
AND MOST IMPORTANTLY, thanks again for all that you do!
in your bruteforce solution , u can also dicard visited set instead take a set and push all the elements into it that way u dont have to keep track of visited elements
This 3 pointer solution, is it some kind of pattern/known way of solving problem or just some constructive algo. especially for this problem??
Great explanation
NeetCode Medium Question:
From starting to till now how many different intro is used by Navdeep if today's intro is "Hey, Everyone welcome back, and lets write some NeetCode".
Answer : 2 , As on his first video he can't be saying Welcome Back coz everyone was coming for first time. (I don't know why I commented this...)
Started to solve the problem thinking i got this. TLE got the best of me
what was your approach?
@@akarsan9121 very ugly brute force checking each element with prime numbers then pushing to ans array and returning last element
@@Nischal.shetty02 same actually, I thought of checking for combination of factors and then adding to list
For the last solution - how to prove or illustrate that we need just three pointers?
I.e.: we created the pointers only for the first ramification. When we get more subtrees, how do we know that we do not need to introduce more pointers to track more "racing" numbers? Why i2, i3, and i5 will always have the current minimum among them?
After looking at the code - I think, a possible explanation can be: all i2, i3, and i5 are moving through ALL numbers calculated one by one, so they will exhaust all options
Every number is beautiful, there are no Ugly numbers.
neetcode stop seshing us, the dp solution is in O(n)! bro what do i do if google asks me to optimize the heap solution - i am cooked (this is half a joke)
dont understand the intuition at all. I mean multiplying 1 by 2,3,5 and then all of the children of one with 2,3,5 makes sense but not sure how I would ve come to the conculsion to use min heaps and use the smallest. Maybe due to the lack of my graph knowledge...
Thank you !
Still a year of daily grinding to go until I get my leetcode shirt 😆
you get a leetcode shirt when
BFS with a Heap
How I can come up to the solution without seen problem before !!?
the second approach was not much intuitive ig.
i guess it becomes easy after you figure out graph and idea of a 3 pointer but that is still difficult
first
🏆
what. the.
First!
🏆
Mid