you are "The" best teacher In terms of explanation I have tried many RUclipsrs like Codehelp, kunal kushwaha but your way of explaining things is much better as you focus on approach not only on coding the things without visualizing possibilities may god bless you for helping many Tier 3 students like me for providing this premium content just for free!
This man is magic when comes to a certain set of problems!!!.... Simply, impressed by him! The explanation easily depicts how much hardwork he has put in! HandsOff to you sir!❤
You win our hearts in every video, specially the hard problems by explaining them in such a beautiful and simple manner. Thank you for your enormous contributions toward the Coding Community❤
I solved this question just after you explained the question, and this is because you explained previous questions so well, and this is the power of your teaching
I am getting crazy with every next video full of excitement and respect for you. How easy , clean , structured the problem and its solution . Best part when the complete story ends with code same as the story we listen, we read it too by the code.
13:24 like he says that range can be optimized. The more optimal lower bound for search space will be the Minimum(adjacent difference). Reason: Let's take array [100, 200, 240, 400, 800]. In this 40 would be the lower bound and not starting from 1. Because if you want to place minimum 2 cows (like question says). You cannot attain difference any lower than this in sorted array which is 40 in this case i.e. Minimum(adjacent difference)
i think you should also optimise the check function a bit more by using lowerbound instead of linear search for the next cow stall index, great solution thought
I solved this question without watching the video just because of the fact that I knew that binary search on answers is going to be applied here, but my question is that how the hell can someone come up with the binary search approach if he/she doesn't know that it is going to be solved using binary search. When I first read this question, the first thought that came to my mind was applying dp.
That's the thing which comes with practice. The more you practice, the more you will solve problems on different topics and you will be able to find patterns in it.
hey @techmaniac2002 now it has been 8 months since you said this and i think you might have practiced many questions since then, and so i wanted to know if you can now find the pattern and say that this question is going to be solved by this approach. or are you still struggling
@@ronakraj I think clear distinction between when to apply binary search or DP is that: whenever you observe that answer always lie between a fixed range, and you are getting an answer till a specific point and not getting any answer after a certain value (this is known as monotonic function) then for sure Binary Search can be applied. Whereas in DP, you will be asked to find the optimal answer (minimum or maximum, just like Binary Search) but the problem would be such that you HAVE TO explore all the answers and only after that determine optimal one, this is where recursion comes in which is used to explore all possibilities and finally overlapping subproblems in recursion are optimized using DP. But these things take time and practice.
In the context of this problem, you could also start with low = 1 since it doesn't make sense to have two rooms at the exact same position. The only reason to start with 0 is to provide a clear lower bound for the binary search. The result wouldn't be affected either way since the binary search would quickly discard unfeasible distances, but starting from 1 would be more intuitive in this context.
Understood well Sir ... Thank you so much Striver Sir for making such an amazing video... After understanding the problem, I was able to solve without seeing the code Thanks a lot Sir
Sir I had a query. Since I'm learning DSA for the first time. Should I solve the easy questions of all topics and then move to their medium and hard questions. or study a topic like easy>medium>hard and then next topic?
You're seriously a legend 🔥🔥🔥 you made me consistent to dsa Thanks a lot❤ Those who cannot find this question on leetcode, there's a question as 1552. Magnetic Force Between Two Balls which is as same as this you can do that.
My approach sort the array, create an array arrd with difference between consecutive elemnts of the array, if k==2 asign first and last (max distance) if more in arrd, sort it pop until k, the last k poped gives min distance
Sir compang will start coming within a month, please upload all the most imp question whivh uou have still not uploaded, topics/question will u think are more important than others!!
Is it only me or any one else have also felt that the binary search medium problems are a bit doable rather than the easy problems... They seem to be hard. However, doesn't this problem seems to be a. 90% similar to minimum days to ship d packages or m bouquet flowers problem.
Aggressive striver
😂😂😭
you are "The" best teacher In terms of explanation
I have tried many RUclipsrs like Codehelp, kunal kushwaha but your way of explaining things is much better as you focus on approach not only on coding the things without visualizing possibilities
may god bless you for helping many Tier 3 students like me for providing this premium content just for free!
Series from Kunal are incomplete. Even after recent updates, its quite far from completion.
Neetcode is pretty good
@@albedo9617 yes
This man is magic when comes to a certain set of problems!!!.... Simply, impressed by him! The explanation easily depicts how much hardwork he has put in! HandsOff to you sir!❤
You win our hearts in every video, specially the hard problems by explaining them in such a beautiful and simple manner.
Thank you for your enormous contributions toward the Coding Community❤
I searched for aggressive cow solution and i got you THE BEST EXPLANATION
Clearly Understood Striver. Thanks for this awesome series.
I solved this question just after you explained the question, and this is because you explained previous questions so well, and this is the power of your teaching
Understood! Super amazing explanation as always, thank you so so much for your continuous effort!!
The best explanation for Aggressive Cows problem!
I am getting crazy with every next video full of excitement and respect for you. How easy , clean , structured the problem and its solution . Best part when the complete story ends with code same as the story we listen, we read it too by the code.
Your explanation is so clear that even beginners can also understand easily.
Habibi issme thoda mushkil hua samjne me but dimak lagai toh samaj aagai ....tusssi ek number kaam karta hai ...acchi bideo banaata hai
coded optimal in one go , without seeing video 😀 . THANKS A LOT STRIVER FOR EVERYTHING
13:24 like he says that range can be optimized. The more optimal lower bound for search space will be the Minimum(adjacent difference). Reason: Let's take array [100, 200, 240, 400, 800]. In this 40 would be the lower bound and not starting from 1. Because if you want to place minimum 2 cows (like question says). You cannot attain difference any lower than this in sorted array which is 40 in this case i.e. Minimum(adjacent difference)
Understand everything
Min Of Max pattern super duper clear
Loved the video. I was stuck in this problem. You have a way with explanations, thanks Striver.
Is binary search that easy, or is it the sriver effect? 😊
yes it obviously strivers effect.
Definately his effect💯💯
woh sirf lagta hai, new problem try karo
After reading the problem statement, I didn't even understand it. It is crystal clear after watching your explanation! Thanks Striver :)
understood
Thank you striver for such an amazing explanation
UNDERSTOOD...Thank You So Much for this wonderful video.............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
i think you should also optimise the check function a bit more by using lowerbound instead of linear search for the next cow stall index, great solution thought
I solved this question without watching the video just because of the fact that I knew that binary search on answers is going to be applied here, but my question is that how the hell can someone come up with the binary search approach if he/she doesn't know that it is going to be solved using binary search. When I first read this question, the first thought that came to my mind was applying dp.
That's the main problem bro.
That's the thing which comes with practice. The more you practice, the more you will solve problems on different topics and you will be able to find patterns in it.
hey @techmaniac2002 now it has been 8 months since you said this and i think you might have practiced many questions since then, and so i wanted to know if you can now find the pattern and say that this question is going to be solved by this approach. or are you still struggling
@@ronakraj Nope, I haven't practiced many questions on DSA since I got placed in the month of August 🙂 I practically left DSA/CP since then...
@@ronakraj I think clear distinction between when to apply binary search or DP is that: whenever you observe that answer always lie between a fixed range, and you are getting an answer till a specific point and not getting any answer after a certain value (this is known as monotonic function) then for sure Binary Search can be applied. Whereas in DP, you will be asked to find the optimal answer (minimum or maximum, just like Binary Search) but the problem would be such that you HAVE TO explore all the answers and only after that determine optimal one, this is where recursion comes in which is used to explore all possibilities and finally overlapping subproblems in recursion are optimized using DP. But these things take time and practice.
Understood !!!!! Grateful of you, Striver🙏
best explanation and intuition
Best Explanation ...............
Best Course on youtube
Aggressive understood lol. Great explanation striver!
Understood very good explanation than previous explanation
Genereally i never do any comment to video but the guys was insane.. this made DSA too easy for mr (I feel slowly slowly DSA is cup of my v tea)
Heyyy, Thanks for the polarity change explanation. I was shocked understanding the intution
Understood...so simple explanation bhaiya💙
clearly understood bro .awesome explanation!!!
Thank you! Lots of gratitude 🌸
Thank u so much, u are very helpful
greeting from Egypt
thank you striver understood everything 🙂
Bht hi badiya padaya bhai, maja agya
your dedication . god bless you
great explanation, easily understood...............
amazing explanation as always striver bhaiya
In the context of this problem, you could also start with low = 1 since it doesn't make sense to have two rooms at the exact same position. The only reason to start with 0 is to provide a clear lower bound for the binary search. The result wouldn't be affected either way since the binary search would quickly discard unfeasible distances, but starting from 1 would be more intuitive in this context.
Ya you can write but it wont make any difference in the time taken... The change in time taken is less than 1ms
great Explanation
luv u brother
Super Sir Understood Thankyou for this Lecture
The best explanation for aggressive cows problem🙂
yes yes, still watching and iked.. tysm
Understood,Thanks striver for this amazing video.
Understood very well
amazing explanation thanks a lot .😊
Just amazing content , I was unable to understand the question but now i am able to solve it. 💌💌💌🤟
Understood Sir, Thank you
you are extradinary man!!💛💯
since we have to min of max distance we'll have to find divide the distances as equal as possible , then choose the minimum
Understood and Thank you
superb explanation
Striver! What's next after this amazing BS Playlist?
amazing question!
Understood well Sir ... Thank you so much Striver Sir for making such an amazing video... After understanding the problem, I was able to solve without seeing the code Thanks a lot Sir
Thank you soooooooo much 😁
someone give him a oscar for the best explanation
In the canweplace func, is it okay to do if(cntcows==cows) return true, rather than >= ?
Bhaiya thanku for the course,but kab tk complete hoga?pls tell
can we do it like this place one cow in start one cow at thee end and then think something like that??
19:01 we are sorting as well. O(nlogn)
Understood !! Beautifully explained
Thank you sir.....❤️
Well, That was lovely.
Hello Striver,I am not able to solve the problems on my own what should i do?
Understood 💯💯💯
Thanks a lot Bhaiya
what about the time complexity of sorting ? we need to add it right ?
Thanks a lot
but for the first approach it is neccessary to sort ?
Sir I had a query. Since I'm learning DSA for the first time. Should I solve the easy questions of all topics and then move to their medium and hard questions. or study a topic like easy>medium>hard and then next topic?
Solve easy ones , once you have done around 50-60 easy questions then move to
Don't we need to sort the array in linear search too? It should add an extra nlogn to the time complexity right?
Yes small things, you are smart now ;)
@@takeUforwardaww
can we do it using dp i tried it but wasn't getting the correct ans
Thanks!
understood 😇
You're seriously a legend 🔥🔥🔥 you made me consistent to dsa
Thanks a lot❤
Those who cannot find this question on leetcode, there's a question as 1552. Magnetic Force Between Two Balls which is as same as this you can do that.
Understood✅🔥🔥
Understood 🎉
why is it necessary to fix the first cow at the first position?
Taking high and low is logical and tricky to solve porblem in much more optimal way
Can you solve this in O(n * log(n)) time complexity?
Not gonna lie, Binary search made it look so simple.
#best #explnation
u r awesome...
Understood !! 😎😎
UNDERSTOOD
Understood!
Understood:)
understood sir
Understood
My approach sort the array, create an array arrd with difference between consecutive elemnts of the array, if k==2 asign first and last (max distance) if more in arrd, sort it pop until k, the last k poped gives min distance
pls add the link of gfg do not remove from sde sheet
pls pls
Understoooooooooooooood!
jai jinendra sir
Sir compang will start coming within a month, please upload all the most imp question whivh uou have still not uploaded, topics/question will u think are more important than others!!
great striver i thought of DP in this question but the constraint are just too high
can apply recursion here but we will have to take care of lot of things in that solution
Is it only me or any one else have also felt that the binary search medium problems are a bit doable rather than the easy problems... They seem to be hard. However, doesn't this problem seems to be a. 90% similar to minimum days to ship d packages or m bouquet flowers problem.
Can we solve this without altering the data(without sorting)?
No , because binary search only applicable in Sorted array 👍
Farthest would be (max - min) / (cows - 1)
Understood sir 😉🤍