Superb explanation! One point I'd like to add here is that the reason why the heap-based solution doesn't work is that if you look at the constraints, the number can range up to 10^9, whereas the inventory length can range up to 10^5, that's why the sorting + the greedy approach is the efficient approach here!
I tried coding the soultion out just from the explation, without using the formulas, and it timed out. Who can come up with these formulas during a 45 mins interview unless they have memorised it :D
You could have used some meaningful names. Also you didn't explain in the code that how is the case of having multiple rods of maximum height is being handled. It is not intuitive from the code.
Such a nice explanation however the coding part was really bad I just got lost x, l, r etc. I wish you would have used good variable names and provide some details while writing the formula.
As a Google Developer, shuldn't you be giving some better variable names rather than random x,y,o?? Dont get me wrong- your explanation is great, but its frustrating to read and understand your code when your variables names are so horrible! Please use better variable names!
i also came up with the heap based solution but i am getting TLE for the test case:- inventory = [1000000000], orders = 1000000000. Can you pls tell how to handle this one
Your explanations would go much further if you used more understandable variable names (even at the cost of writing longer code). Remember, code is meant to be read by humans too!
Superb explanation!
One point I'd like to add here is that the reason why the heap-based solution doesn't work is that if you look at the constraints,
the number can range up to 10^9, whereas the inventory length can range up to 10^5, that's why the sorting + the greedy approach is the efficient approach here!
The way you started was so good and after that when coding part started don't know what you did.
I tried coding the soultion out just from the explation, without using the formulas, and it timed out. Who can come up with these formulas during a 45 mins interview unless they have memorised it :D
12:26 onwards LOST :(
You could have used some meaningful names. Also you didn't explain in the code that how is the case of having multiple rods of maximum height is being handled. It is not intuitive from the code.
great explanation...keep up the good work and thanks a lot
Such a nice explanation however the coding part was really bad I just got lost x, l, r etc. I wish you would have used good variable names and provide some details while writing the formula.
Will keep that in mind. Thanks for the useful suggestions 😊
As a Google Developer, shuldn't you be giving some better variable names rather than random x,y,o?? Dont get me wrong- your explanation is great, but its frustrating to read and understand your code when your variables names are so horrible! Please use better variable names!
Very nice explanation . Keep making more videos 💯
i also came up with the heap based solution but i am getting TLE for the test case:- inventory = [1000000000], orders = 1000000000. Can you pls tell how to handle this one
Watch the video
please attach your code also.
Hey thank you so much for explaining this question. Appreciate the effort :)
Thank you for making this video!!
You're welcome
Keep up the hard work
Thanks
What if we have same number of balls in the inventory I mean when all the elements in vector are same?
Ankita just watch the video carefully , you will your answers.
We are handling this condition as well.
please explain by writing each case separately instead of writing short code (which seems hard to understand).
Alright, will keep in mind
What is l and r in the last approach?
R is the right limit. And l is left limit.
So basically you have to find the sum of all number from left(l)+1 to , right(r)
Hey can you explain how u came up with the formula ret+= l*(X%n-i)
@@mohammadfraz Can you redo the video with a easy to understand explanation?
@@bismeetsingh352 The video is good enough, Watch it again.
@@kishores5121 Sorry, I still dont get it.
Your explanations would go much further if you used more understandable variable names (even at the cost of writing longer code). Remember, code is meant to be read by humans too!
Yes definitely 😊
Which laptop are you using? Are you using a pen
Asus vivobook s14 . Yes I am using digital pen