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)
@abhaychoudhary67462 ай бұрын
but for this you need to traverse the array
@Aryan_o72 ай бұрын
@25:13 @rohitverma1057
@technicalteam3298 Жыл бұрын
you are "The" best teacher In terms of explanation I have tried many KZbinrs 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!
@anshulgoel1940 Жыл бұрын
Series from Kunal are incomplete. Even after recent updates, its quite far from completion.
@albedo96175 ай бұрын
Neetcode is pretty good
@rickk33005 ай бұрын
@@albedo9617 yes
@Josuke2174 ай бұрын
Exactly, Babbar hasn't covered topics in depth . Kunal of course hasn't completed the course
@himanshurane4847 Жыл бұрын
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
@341yes Жыл бұрын
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!❤
@manojkumar-hr7tj27 күн бұрын
Just by looking at the comments, I wanted to give a try and got succeeded. Thanks Striver!!!
@Bigg_boss_trolls2 күн бұрын
you are "The" best teacher In terms of explanation
@AkshayGoel-of8ic Жыл бұрын
I searched for aggressive cow solution and i got you THE BEST EXPLANATION
@devgarg43319 ай бұрын
coded optimal in one go , without seeing video 😀 . THANKS A LOT STRIVER FOR EVERYTHING
@harshpanwar1550 Жыл бұрын
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❤
@lavanya_m017 ай бұрын
After reading the problem statement, I didn't even understand it. It is crystal clear after watching your explanation! Thanks Striver :)
@reshmah149719 күн бұрын
Very good explanation Striver! Thanks a lot for these teachings. These are a great source of knowledge for tier-4 colleges too.
@visase2036 Жыл бұрын
I have been asked a similar question when i appeared for Google , the question was : The city is affected with Covid 19 and hospitals are filling up with patients. As a doctor , you need to make sure the patients are treated well. To do so You have some patients and beds for them to be allocated and the survival rate of the patients will be higher only if they are placed as far as possible. Given m beds and n patients maximize the minimum distance between any two patients to increase the survival rate. Ans : Same Binary Search approach .
@kartikeyrana3736 Жыл бұрын
were you selected ?
@visase2036 Жыл бұрын
@@kartikeyrana3736 yes , but no :). Moved to the next rounds but on hold due to hiring freeze!
@munvut87710 ай бұрын
this question is same as this!
@elizabethr5161 Жыл бұрын
Clearly Understood Striver. Thanks for this awesome series.
@aniketwdubey Жыл бұрын
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.
@soumojjalsen191510 ай бұрын
Ya you can write but it wont make any difference in the time taken... The change in time taken is less than 1ms
@ujjawalraj6096 Жыл бұрын
Understand everything Min Of Max pattern super duper clear
@pradipkumarmukhiАй бұрын
Grateful beyond words, Striver! You transformed the Aggressive Cows problem from a daunting challenge to a clear solution. Your explanation not only sharpened my DSA skills but also boosted my confidence in problem-solving. Huge thanks for your patience and precision!❤❤
@52nevil36 Жыл бұрын
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)
@aaryanjavalekar7249 Жыл бұрын
The best explanation for Aggressive Cows problem!
@priyanshigusain67222 ай бұрын
i am really really really X 100000 speechless he is am amazing teacher means he makes the problem look like it's nothing i have never met such simplified teacher you are serendipity encounter for me😇😇🤩🤩🤩.
@NonameNoname-f2t9 ай бұрын
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.
@rickk3300 Жыл бұрын
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.
@utsavseth6573 Жыл бұрын
That's the main problem bro.
@bishalkundu7592 Жыл бұрын
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.
@ronakraj7 ай бұрын
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
@rickk33007 ай бұрын
@@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...
@chetanraghavv6 ай бұрын
@@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.
@CodeMode9313 Жыл бұрын
Habibi issme thoda mushkil hua samjne me but dimak lagai toh samaj aagai ....tusssi ek number kaam karta hai ...acchi bideo banaata hai
@rintugayen24354 ай бұрын
Hanuman chalisa padhke iss lecture ko dekh samajh aa jayega
@RaunitJaiswal-s9v2 ай бұрын
😂@@rintugayen2435
@PriyamJamwal4 ай бұрын
based on AP, to optimize further you can set high = ceil((double)(stall[n-1] - stall[0]) / (double)c) stall is array of sorted stalls, c is no. of cows
@stith_pragya9 ай бұрын
UNDERSTOOD...Thank You So Much for this wonderful video.............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@venkatamurthy6022 Жыл бұрын
Your explanation is so clear that even beginners can also understand easily.
@revanthchouhan30683 ай бұрын
Man, you're built different. You make everything understandable! Keep doing the same
@sxd6259 Жыл бұрын
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
@shaikkhizar81339 ай бұрын
Super Sir Understood Thankyou for this Lecture
@souvikbiswas2842 ай бұрын
I understood the question at 07:20 and coded the answer. The question is almost similar to "Find the smaller divisor". All thanks to you Striver, your explanation of the approach has helped me to come up with the answer on my own.. 😍😍❤❤
@souvikbiswas2842 ай бұрын
Here's the Solution: class Solution: def aggressiveCows(self, nums, k): nums.sort() n = len(nums) l = 0 r = nums[-1] - nums[0] while l > 1) cows_placed = 1 last_pos = nums[-1] for curr in range(n-2, -1, -1): if last_pos - nums[curr] >= distance: cows_placed += 1 last_pos = nums[curr] if cows_placed >= k: break if cows_placed < k: r = mid - 1 return r
@Video-Notes6 ай бұрын
Best Explanation ............... Best Course on youtube
@pushpendrasingh7772 ай бұрын
I coded it on my own after you explained the approach
@arjunthakur58278 ай бұрын
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
@manitoshpaul61705 ай бұрын
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.
@graviton0013 ай бұрын
Yes I find all medium problems quiet similar 😅 and I did it myself
@Fe-ironmanАй бұрын
5-10 were most difficult after that most were easy
@farheenahmed82865 ай бұрын
The best explanation for aggressive cows problem🙂
@simransaini12274 ай бұрын
Understood !!!!! Grateful of you, Striver🙏
@samsmith3961 Жыл бұрын
since we have to min of max distance we'll have to find divide the distances as equal as possible , then choose the minimum
@patilrajesh2500Ай бұрын
Lecture successfully completed on 22nd October 2024🔥🔥
@cinime Жыл бұрын
Understood! Super amazing explanation as always, thank you so so much for your continuous effort!!
@darrienxavier55363 ай бұрын
In the Brute Force approach return i-1 won't work in all cases , we could use a variable to keep track of the distance and then return it
@rohakdebnath898511 ай бұрын
Loved the video. I was stuck in this problem. You have a way with explanations, thanks Striver.
@AK-nj1je8 ай бұрын
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.
@Manishgupta200 Жыл бұрын
Taking high and low is logical and tricky to solve porblem in much more optimal way
@sauravchandra10 Жыл бұрын
Is binary search that easy, or is it the sriver effect? 😊
@myamazonproducts1683 Жыл бұрын
yes it obviously strivers effect.
@deeptidip9864 Жыл бұрын
Definately his effect💯💯
@varunaggarwal7126 Жыл бұрын
woh sirf lagta hai, new problem try karo
@ShobhitRaghuwanshi-lx2nt4 ай бұрын
@@varunaggarwal7126 true 😂
@sushantguria882024 күн бұрын
What a great explanation, thank you sir
@rajveersingh2056 Жыл бұрын
Farthest would be (max - min) / (cows - 1)
@naveensingh596 Жыл бұрын
Understood...so simple explanation bhaiya💙
@PrajwalCoding11 ай бұрын
Heyyy, Thanks for the polarity change explanation. I was shocked understanding the intution
@debanjanghosal618Ай бұрын
This is a max(min) problem. This is because we are maximizing the minimum distance between any two cows.
@samarthpai535920 күн бұрын
Wonderful explaination! understood
@AtulKumar-c4x7l Жыл бұрын
understood Thank you striver for such an amazing explanation
@MaheshPatil-of1zy2 ай бұрын
in the brute force approach the time complexity of the sorting is not included.
@rishabh1S Жыл бұрын
Not gonna lie, Binary search made it look so simple.
@umairislam871523 күн бұрын
You are amazing Striver❤
@krishnasharma-rn3sd4 ай бұрын
clearly understood bro .awesome explanation!!!
@kaichang8186Ай бұрын
understood, thanks for the perfect explanation
@shashikumar23829 ай бұрын
Just amazing content , I was unable to understand the question but now i am able to solve it. 💌💌💌🤟
@Sahilsharma-sk5vr5 ай бұрын
your dedication . god bless you
@samreenimam860810 ай бұрын
yes yes, still watching and iked.. tysm
@RobinSingh-nf4oo2 ай бұрын
explanation on top🔥🔥🔥🔥
@nihaal46997 ай бұрын
Bht hi badiya padaya bhai, maja agya
@ritwik121 Жыл бұрын
someone give him a oscar for the best explanation
@varun_immadisettiАй бұрын
crystal clear sir
@Musicuvakavi18237 ай бұрын
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
@bhagyashreekhairnar6839 ай бұрын
Thank you! Lots of gratitude 🌸
@shantipriya37011 ай бұрын
superb explanation
@hareshnayak73027 ай бұрын
Understood,Thanks striver for this amazing video.
@chetnaraghav997911 күн бұрын
Thank you Striver
@abdulrhmanmagdy7591 Жыл бұрын
Thank u so much, u are very helpful greeting from Egypt
@dayashankarlakhotia4943 Жыл бұрын
Understood very good explanation than previous explanation
@GauravJain-zo8gt5 ай бұрын
jai jinendra sir
@satwiksrivastava4 ай бұрын
Today this problem was asked in Salesforce intern OA with the name of fighting children 😂 The joy of mapping the algorithm.
@DM2K63 ай бұрын
almost did on my own. thanks striver
@javabytharun4 ай бұрын
great explanation, easily understood...............
@faizanahmed9304 Жыл бұрын
19:01 we are sorting as well. O(nlogn)
@prathameshthorat93504 ай бұрын
Similar Question on Leetcode : 1552. Magnetic Force Between Two Balls
@usmankhatri6836 Жыл бұрын
Striver! What's next after this amazing BS Playlist?
@priyankaranawat83735 ай бұрын
Thank you soooooooo much 😁
@aruna58695 ай бұрын
you are extradinary man!!💛💯
@alishashaikh3859 Жыл бұрын
Hello Striver,I am not able to solve the problems on my own what should i do?
@sauravkumarjha6162 Жыл бұрын
amazing explanation as always striver bhaiya
@dhruvmalik8052 Жыл бұрын
great Explanation luv u brother
@dipingrover19705 ай бұрын
amazing explanation thanks a lot .😊
@culeforever5408 Жыл бұрын
understood 😇
@Shunya_Advait Жыл бұрын
Understood Sir, Thank you
@VishalGupta-xw2rp Жыл бұрын
22:05 Opposite Polarity
@ishangujarathi10 Жыл бұрын
best explanation and intuition
@MJBZG4 ай бұрын
amazing question!
@crazymemes40803 ай бұрын
i am preparing for offcampus :) thank you for everything.
@oyeesharme3 ай бұрын
understood bhaiya
@ashfakahamed9266 Жыл бұрын
If "Find min or find max" is what you will use to identify Binary Search then eventually you will get stuck in the DP problems
@shreyasingh1960 Жыл бұрын
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!!
@arunsagarsa36134 ай бұрын
@takeUforward The moment I get my job with this channels' help, I shall thank you and join the KZbin channel.
@rockykumarverma9802 ай бұрын
Thank you so much sir🙏🙏🙏
@VarshaSingh-hi2sb2 ай бұрын
Why we are always placing the cow at first index only. There can be combinations where placing at first and all cows are placed then also places would be left to place more cows . So it is also possible that if we started from positon other than first it might have possible to place all the cows so why always position 1?
@hamzarehman7057 Жыл бұрын
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?
@ganakkathuria3645 Жыл бұрын
Solve easy ones , once you have done around 50-60 easy questions then move to