BS-17. Aggressive Cows | Binary Search Hard

  Рет қаралды 130,300

take U forward

take U forward

Жыл бұрын

Problem Link: bit.ly/3J9ab1B
Notes/C++/Java/Python codes: Soon
We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of Course

Пікірлер: 212
@sus_tha_coder
@sus_tha_coder Жыл бұрын
Aggressive striver
@shreyasingh1960
@shreyasingh1960 Жыл бұрын
😂😂😭
@SuyashKumar-fd7gl
@SuyashKumar-fd7gl 17 күн бұрын
😂
@technicalteam3298
@technicalteam3298 11 ай бұрын
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
@anshulgoel1940 10 ай бұрын
Series from Kunal are incomplete. Even after recent updates, its quite far from completion.
@albedo9617
@albedo9617 Ай бұрын
Neetcode is pretty good
@rickk3300
@rickk3300 Ай бұрын
@@albedo9617 yes
@rohitverma1057
@rohitverma1057 6 ай бұрын
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)
@user-ik3qu5uy5e
@user-ik3qu5uy5e 5 ай бұрын
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.
@elizabethr5161
@elizabethr5161 Жыл бұрын
Clearly Understood Striver. Thanks for this awesome series.
@AkshayGoel-of8ic
@AkshayGoel-of8ic Жыл бұрын
I searched for aggressive cow solution and i got you THE BEST EXPLANATION
@341yes
@341yes 11 ай бұрын
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!❤
@cinime
@cinime Жыл бұрын
Understood! Super amazing explanation as always, thank you so so much for your continuous effort!!
@harshpanwar1550
@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❤
@himanshurane4847
@himanshurane4847 9 ай бұрын
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
@aaryanjavalekar7249
@aaryanjavalekar7249 Жыл бұрын
The best explanation for Aggressive Cows problem!
@devgarg4331
@devgarg4331 5 ай бұрын
coded optimal in one go , without seeing video 😀 . THANKS A LOT STRIVER FOR EVERYTHING
@lavanyam3224
@lavanyam3224 3 ай бұрын
After reading the problem statement, I didn't even understand it. It is crystal clear after watching your explanation! Thanks Striver :)
@venkatamurthy6022
@venkatamurthy6022 Жыл бұрын
Your explanation is so clear that even beginners can also understand easily.
@rohakdebnath8985
@rohakdebnath8985 7 ай бұрын
Loved the video. I was stuck in this problem. You have a way with explanations, thanks Striver.
@sxd6259
@sxd6259 11 ай бұрын
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
@ujjawalraj6096
@ujjawalraj6096 Жыл бұрын
Understand everything Min Of Max pattern super duper clear
@PrajwalCoding
@PrajwalCoding 7 ай бұрын
Heyyy, Thanks for the polarity change explanation. I was shocked understanding the intution
@stith_pragya
@stith_pragya 5 ай бұрын
UNDERSTOOD...Thank You So Much for this wonderful video.............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@Video-Notes
@Video-Notes 2 ай бұрын
Best Explanation ............... Best Course on youtube
@simransaini1227
@simransaini1227 22 күн бұрын
Understood !!!!! Grateful of you, Striver🙏
@52nevil36
@52nevil36 10 ай бұрын
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)
@user-ti3bd8mp1w
@user-ti3bd8mp1w Жыл бұрын
understood Thank you striver for such an amazing explanation
@farheenahmed8286
@farheenahmed8286 Ай бұрын
The best explanation for aggressive cows problem🙂
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
Understood very good explanation than previous explanation
@aniketwdubey
@aniketwdubey 8 ай бұрын
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.
@soumojjalsen1915
@soumojjalsen1915 6 ай бұрын
Ya you can write but it wont make any difference in the time taken... The change in time taken is less than 1ms
@nihaal4699
@nihaal4699 3 ай бұрын
Bht hi badiya padaya bhai, maja agya
@naveensingh596
@naveensingh596 9 ай бұрын
Understood...so simple explanation bhaiya💙
@krishnasharma-rn3sd
@krishnasharma-rn3sd 22 күн бұрын
clearly understood bro .awesome explanation!!!
@shashikumar2382
@shashikumar2382 5 ай бұрын
Just amazing content , I was unable to understand the question but now i am able to solve it. 💌💌💌🤟
@ishangujarathi10
@ishangujarathi10 Жыл бұрын
best explanation and intuition
@shaikkhizar8133
@shaikkhizar8133 5 ай бұрын
Super Sir Understood Thankyou for this Lecture
@CodeMode9313
@CodeMode9313 11 ай бұрын
Habibi issme thoda mushkil hua samjne me but dimak lagai toh samaj aagai ....tusssi ek number kaam karta hai ...acchi bideo banaata hai
@rintugayen2435
@rintugayen2435 13 сағат бұрын
Hanuman chalisa padhke iss lecture ko dekh samajh aa jayega
@srikanthmedicherla4841
@srikanthmedicherla4841 Жыл бұрын
Aggressive understood lol. Great explanation striver!
@abdulrhmanmagdy7591
@abdulrhmanmagdy7591 Жыл бұрын
Thank u so much, u are very helpful greeting from Egypt
@bhagyashreekhairnar683
@bhagyashreekhairnar683 5 ай бұрын
Thank you! Lots of gratitude 🌸
@hareshnayak7302
@hareshnayak7302 3 ай бұрын
Understood,Thanks striver for this amazing video.
@samreenimam8608
@samreenimam8608 6 ай бұрын
yes yes, still watching and iked.. tysm
@sauravkumarjha6162
@sauravkumarjha6162 9 ай бұрын
amazing explanation as always striver bhaiya
@Sahilsharma-sk5vr
@Sahilsharma-sk5vr Ай бұрын
your dedication . god bless you
@sauravchandra10
@sauravchandra10 Жыл бұрын
Is binary search that easy, or is it the sriver effect? 😊
@myamazonproducts1683
@myamazonproducts1683 Жыл бұрын
yes it obviously strivers effect.
@deeptidip9864
@deeptidip9864 Жыл бұрын
Definately his effect💯💯
@varunaggarwal7126
@varunaggarwal7126 11 ай бұрын
woh sirf lagta hai, new problem try karo
@ShobhitRaghuwanshi-lx2nt
@ShobhitRaghuwanshi-lx2nt 12 күн бұрын
​@@varunaggarwal7126 true 😂
@samsmith3961
@samsmith3961 11 ай бұрын
since we have to min of max distance we'll have to find divide the distances as equal as possible , then choose the minimum
@javabytharun
@javabytharun 27 күн бұрын
great explanation, easily understood...............
@Musicuvakavi1823
@Musicuvakavi1823 3 ай бұрын
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
@rickk3300
@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
@utsavseth6573 11 ай бұрын
That's the main problem bro.
@bishalkundu7592
@bishalkundu7592 9 ай бұрын
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.
@ronakraj
@ronakraj 3 ай бұрын
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
@rickk3300
@rickk3300 3 ай бұрын
@@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...
@chetanraghavv
@chetanraghavv 2 ай бұрын
@@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.
@dipingrover1970
@dipingrover1970 Ай бұрын
amazing explanation thanks a lot .😊
@aruna5869
@aruna5869 Ай бұрын
you are extradinary man!!💛💯
@manavsingh5919
@manavsingh5919 10 ай бұрын
thank you striver understood everything 🙂
@dhruvmalik8052
@dhruvmalik8052 11 ай бұрын
great Explanation luv u brother
@AK-nj1je
@AK-nj1je 4 ай бұрын
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.
@Shunya_Advait
@Shunya_Advait 11 ай бұрын
Understood Sir, Thank you
@varun1017
@varun1017 5 ай бұрын
superb explanation
@shra1
@shra1 Жыл бұрын
Understood very well
@MJBZG
@MJBZG 22 күн бұрын
amazing question!
@joeljacob4685
@joeljacob4685 9 ай бұрын
Understood !! Beautifully explained
@usmankhatri6836
@usmankhatri6836 11 ай бұрын
Striver! What's next after this amazing BS Playlist?
@PriyamJamwal
@PriyamJamwal 18 күн бұрын
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
@Manishgupta200
@Manishgupta200 Жыл бұрын
Taking high and low is logical and tricky to solve porblem in much more optimal way
@ritwik121
@ritwik121 Жыл бұрын
someone give him a oscar for the best explanation
@arjunthakur5827
@arjunthakur5827 4 ай бұрын
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
@user-or5oz1pk2x
@user-or5oz1pk2x 2 ай бұрын
Thanks a lot Bhaiya
@ankitdhattarwal2286
@ankitdhattarwal2286 Жыл бұрын
Understood and Thank you
@priyankaranawat8373
@priyankaranawat8373 Ай бұрын
Thank you soooooooo much 😁
@shreyasingh1960
@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!!
@GauravJain-zo8gt
@GauravJain-zo8gt Ай бұрын
jai jinendra sir
@faizanahmed9304
@faizanahmed9304 Жыл бұрын
19:01 we are sorting as well. O(nlogn)
@utsavseth6573
@utsavseth6573 11 ай бұрын
Well, That was lovely.
@manishkaushik6526
@manishkaushik6526 10 ай бұрын
but for the first approach it is neccessary to sort ?
@lakshmiprasanna7058
@lakshmiprasanna7058 Жыл бұрын
Understood 💯💯💯
@PriyankaSingh-sl2wg
@PriyankaSingh-sl2wg 8 ай бұрын
Thank you sir.....❤️
@user-is6ky7pp2n
@user-is6ky7pp2n Ай бұрын
Understood !! 😎😎
@zooomba62
@zooomba62 6 ай бұрын
what about the time complexity of sorting ? we need to add it right ?
@YourCodeVerse
@YourCodeVerse 7 ай бұрын
Understood✅🔥🔥
@culeforever5408
@culeforever5408 8 ай бұрын
understood 😇
@rohanpathak
@rohanpathak Жыл бұрын
Bhaiya thanku for the course,but kab tk complete hoga?pls tell
@gauravbanerjee2898
@gauravbanerjee2898 3 ай бұрын
Thanks a lot
@satwiksrivastava
@satwiksrivastava 2 күн бұрын
Today this problem was asked in Salesforce intern OA with the name of fighting children 😂 The joy of mapping the algorithm.
@Chandraprakash-kx4ic
@Chandraprakash-kx4ic Жыл бұрын
#best #explnation
@her_soulmate
@her_soulmate 6 ай бұрын
Understood 🎉
@hamzarehman7057
@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
@ganakkathuria3645 Жыл бұрын
Solve easy ones , once you have done around 50-60 easy questions then move to
@ayushagarwal5271
@ayushagarwal5271 Ай бұрын
In the canweplace func, is it okay to do if(cntcows==cows) return true, rather than >= ?
@amit2197kumar
@amit2197kumar 13 күн бұрын
Can anyone help me understand why we need to sort the array of stalls in the first place? Thanks.
@harshilpatel3205
@harshilpatel3205 5 ай бұрын
Understood sir 😉🤍
@thenriquevicentini
@thenriquevicentini 2 ай бұрын
Understood!
@rajveersingh2056
@rajveersingh2056 11 ай бұрын
Farthest would be (max - min) / (cows - 1)
@aaronargottelopez3488
@aaronargottelopez3488 2 ай бұрын
Thanks!
@Nimbus2k_rider
@Nimbus2k_rider Ай бұрын
u r awesome...
@alishashaikh3859
@alishashaikh3859 9 ай бұрын
Hello Striver,I am not able to solve the problems on my own what should i do?
@_SAHILMAHAJAN
@_SAHILMAHAJAN Жыл бұрын
great striver i thought of DP in this question but the constraint are just too high
@te083tejaspatil8
@te083tejaspatil8 8 ай бұрын
can apply recursion here but we will have to take care of lot of things in that solution
@ishaanchandak4774
@ishaanchandak4774 10 ай бұрын
can we do it using dp i tried it but wasn't getting the correct ans
@arihantjammar8888
@arihantjammar8888 11 ай бұрын
UNDERSTOOD
@adgaur090
@adgaur090 10 ай бұрын
understood sir
@user-js1rx8rs9p
@user-js1rx8rs9p 3 ай бұрын
understood striver
@rishabh1S
@rishabh1S 11 ай бұрын
Not gonna lie, Binary search made it look so simple.
@harshitjaiswal9439
@harshitjaiswal9439 11 ай бұрын
Understoooooooooooooood!
@trixxy8304
@trixxy8304 Жыл бұрын
Don't we need to sort the array in linear search too? It should add an extra nlogn to the time complexity right?
@takeUforward
@takeUforward Жыл бұрын
Yes small things, you are smart now ;)
@shreyasingh1960
@shreyasingh1960 Жыл бұрын
​@@takeUforwardaww
@ganeshvhatkar9253
@ganeshvhatkar9253 6 ай бұрын
Understood
@ad_akshat
@ad_akshat 5 ай бұрын
can we do it like this place one cow in start one cow at thee end and then think something like that??
@rahulbhagat4023
@rahulbhagat4023 11 ай бұрын
why is it necessary to fix the first cow at the first position?
@itsmrcrazy7670
@itsmrcrazy7670 9 ай бұрын
waiting for linkedlist videos .>>>
BS-18. Allocate Books or Book Allocation | Hard Binary Search
27:29
take U forward
Рет қаралды 137 М.
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 13 МЛН
One moment can change your life ✨🔄
00:32
A4
Рет қаралды 34 МЛН
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 116 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 10 МЛН
Mastering Google Interview GCD Techniques
6:53
Gurukul
Рет қаралды 145
How to be a good instalock
5:00
S1ntheie
Рет қаралды 141
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
BS-4. Search Element in Rotated Sorted Array - I
16:38
take U forward
Рет қаралды 213 М.
BS-10. Finding Sqrt of a number using Binary Search
17:11
take U forward
Рет қаралды 105 М.
L9. Reverse a LinkedList | Iterative and Recursive
32:42
take U forward
Рет қаралды 97 М.
Winning Google Kickstart Round A 2020 + Facecam
17:10
William Lin
Рет қаралды 9 МЛН
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 13 МЛН