Aggressive Cows | Binary Search | BS-17. Aggressive Cows | Binary Search Hard

  Рет қаралды 102,490

take U forward

take U forward

Күн бұрын

Пікірлер: 275
@takeUforward
@takeUforward Жыл бұрын
Please watch our new video on the same topic: kzbin.info/www/bejne/iJCwl6pqmtxgjNE
@artofwrick
@artofwrick 10 ай бұрын
Problem in leetcode : Magnetic force between 2 balls. Leetcode...
@rogerop6721
@rogerop6721 3 жыл бұрын
similar question on leetcode -> 1552. Magnetic Force Between Two Balls 1870. Minimum Speed to Arrive on Time 875. Koko Eating Bananas 1011. Capacity To Ship Packages Within D Days 1283. Find the Smallest Divisor Given a Threshold 1482. Minimum Number of Days to Make m Bouquets 2064. Minimized Maximum of Products Distributed to Any Store
@zyro9922
@zyro9922 3 жыл бұрын
Thank you man. Really appreciate it
@rogerop6721
@rogerop6721 3 жыл бұрын
@@zyro9922 welcome
@kage-musha1702
@kage-musha1702 3 жыл бұрын
1231 Divide Chocolate 774 Minimize Max Distance to Gas Station 410 Split Array Largest Sum these too :D
@vasujain1970
@vasujain1970 3 жыл бұрын
nice, thanks!
@rithikdutt1332
@rithikdutt1332 3 жыл бұрын
Thankss!
@anujjain9273
@anujjain9273 3 жыл бұрын
for all those who are confuse , at 3:21 the c2 should be drawn under the stall 8 column not under stall 4 , although explanation was good
@takeUforward
@takeUforward 3 жыл бұрын
Checkout out playlist for all DSA in the description. Follow me at Instagram for updates: Striver_79
@prithvijitbasak
@prithvijitbasak 3 жыл бұрын
Thank you sir for this video. This question was not clear for me after watching a video on this question on KZbin. But your explanation is extraordinary ❤️🔥. It's crystal clear for me now. Keep making more these top notch quality content. ❤️❤️🔥.
@worldaffairs2.060
@worldaffairs2.060 3 жыл бұрын
Hindi mein bbhi pdahye sir
@SudhanshuKumar-lp1nr
@SudhanshuKumar-lp1nr 3 жыл бұрын
high=arr[n-1]-arr[0]
@georgebell1927
@georgebell1927 2 жыл бұрын
Striver is the dsa playlist the solns for the sde sheet that u prepared.For example does the linked list playlist consists of the solutions to the linked list problems in the sde sheet.Please answer because if they are the solns i ll watch them after trying the sde sheet.
@jashanbansal2613
@jashanbansal2613 3 жыл бұрын
Aggressive Striver :)
@rishabh_pant
@rishabh_pant Жыл бұрын
😂
@debanjanghosal618
@debanjanghosal618 Ай бұрын
couldn't understand from his new videos but this old gem did the magic for me❤
@soumyadipbhowmik2220
@soumyadipbhowmik2220 2 жыл бұрын
Your explanaining capabilities are absolutely beautiful. People really be coding it out without thinking the approach which you did beautifully.
@nikhilrana2680
@nikhilrana2680 3 жыл бұрын
Aggressive cows , explained in a calm manner, striver bhaiya op🔥
@vinaygupta2369
@vinaygupta2369 2 жыл бұрын
He was also agressive in making solution understood :)
@mohitbajaj4465
@mohitbajaj4465 2 жыл бұрын
we can also take low as the minimum gap between the consecutive element alfter sorting. For example if the array is 10 50 100 200. then we can take low as 40. because that can be the minimum ans if the number of cows is 4. This will reduce the time complexity for binary search. Please correct me if i am wrong.
@lakshsinghania
@lakshsinghania Жыл бұрын
yeah, ig coz in book allocation problem the search space was from max_element ---- sum of all elements altho here we are not finding the sum as the problem statement is diff we need the min distance that is low till the end
@sumitanand6249
@sumitanand6249 2 жыл бұрын
More Good Binary Search Problems (Leetcode). Good luck and have fun! 1539. Kth Missing Positive Number 1482. Minimum Number of Days to Make m Bouquets 1283. Find the Smallest Divisor Given a Threshold 1231. Divide Chocolate 1011. Capacity To Ship Packages In N Days 875. Koko Eating Bananas 774. Minimize Max Distance to Gas Station 410. Split Array Largest Sum
@princebharti1396
@princebharti1396 2 жыл бұрын
thanks a lot for sharing
@sahilgupta5648
@sahilgupta5648 2 ай бұрын
best video for aggressive cows i have Evered watch thanks striver for this amazing content
@rudraprasaddash3809
@rudraprasaddash3809 3 жыл бұрын
Thank you bhaiya for this amazing explanation. But, the "NOOO! WHY?" at 10:40 is epic🤣
@aniketbhusal3489
@aniketbhusal3489 3 жыл бұрын
Your explanation and the topic clearance has grown exponentially with whiteboard, you are gonna progress a lot for sure , no looking back.
@rounakmukherjee9540
@rounakmukherjee9540 2 жыл бұрын
Thanks for those 2 Gems... those are really something that I am searching for . Both in book allocation and Aggressive cows question's, you give a quality explanation that Isolved some similar question like that by my own. Thank you.
@xZero_.
@xZero_. 8 ай бұрын
Incredible Explanation, Thanks for the Tutorial!
@vikashgupta3305
@vikashgupta3305 3 жыл бұрын
Haye your excitement in 10:52, excites me I get more Interested in Q after seeing your interest and energy, which matters me the most for my love of coding. You're true gems in our community I seriously admire your nature and thought process.❤️
@ayushagarwal2091
@ayushagarwal2091 3 жыл бұрын
Your hard work and dedication can be clearly seen from ur eyes🙏🙏🙏
@sandeepnallala48
@sandeepnallala48 3 жыл бұрын
Bro i knew this prblm and still came here see the way u explain, and just after starting hit the like 💯💯💯. Great wrk bro
@devvratsaxena8962
@devvratsaxena8962 3 жыл бұрын
This is honestly one of the best explanation for all the questions I came across ever on youtube. Thanks sir for such awesome content.
@jaiminsolanki5478
@jaiminsolanki5478 3 жыл бұрын
Bro the way u teach, the energy, makes learning so fun and interesting....tysm Brother!
@samreenimam8608
@samreenimam8608 10 ай бұрын
we're finding " do ke bich ki duri jitna ho sake badha do., but within given stalls".
@varshinielangovansumathi6563
@varshinielangovansumathi6563 3 жыл бұрын
Hi! Please upload a video on Time and Space Complexity if possible . I just finished watching your C++ STL video today. You're doing a great job👏. I really like the way you explain things🥺🔥 Thanks a ton 🙏❤️
@giridharjadala2182
@giridharjadala2182 2 жыл бұрын
It was pretty tough to figure out the search space right after going through the question, but your intuition was really good.
@gowthamvb418
@gowthamvb418 Жыл бұрын
Everything in this video is clear and excellent. However I couldn't figure out the below. Can Anyone explains me to clear it out. Why we need to place our first cow in first stall. Placing the first cow in different(next) stalls leads to different answer right? Also why are we assuming min distance of cow as firstly placed two cows, i.e., stall[0] and next upcoming stall[i] that covers min distance, probably min distance will be on next upcoming stalls as well right? Hoping to get clear my doubts. Thanks.
@naro.tam_
@naro.tam_ 3 жыл бұрын
Thanx Striver Bhaiya.came here from your Binary Search master class and I easily solved all the below listed questions .Thanx for these amazing concepts
@abhishekkumarsingh8603
@abhishekkumarsingh8603 3 жыл бұрын
Ek dum mast sequential way mein aa rha hai video pura thought process bana diye hai pura relate kar paye pichle video se pehle toh q dekh ke pata hi nhi chalta tha ki binary search ka q hai 😊
@ratnadeepbhattacharya3237
@ratnadeepbhattacharya3237 3 жыл бұрын
Bhaiya classes k din yaad a gye..... Loved it...... Nd all thanks to u for making such a tough prblm bread and butter.....
@lasanihussain8810
@lasanihussain8810 2 жыл бұрын
Here after binary search master class, was able to do aggressive cows on my own.
@Dead_Zone_0922
@Dead_Zone_0922 2 жыл бұрын
i invest my time to understand 7 hours i have made many times dry and run i try to solve it using sliding window and brute fornce and binary search but i couldn't now i understood complitely thank u bro thank u so mcuh ........
@Bhatkal_Vlogger
@Bhatkal_Vlogger 2 жыл бұрын
how can you place three cows 10:52 mast bhaiya
@wian7284
@wian7284 3 жыл бұрын
"Definitely not!"😅😂 Reminds me of Dhoni saying this :p
@gauravgupta5530
@gauravgupta5530 2 жыл бұрын
18:58 How to place cows;
@aditya_jaiswal.
@aditya_jaiswal. Жыл бұрын
After lot of struggle through many videos finally here I understood this concept 🥰. Kisko credit diya jaye meri mehanat ko ya striver bhaiya❤ ko. yrr sach me book allocation problem ke bad 2 dino se samjhne ki koshish kar rha tha🤒😅
@lawbindpandey402
@lawbindpandey402 3 жыл бұрын
The lesson learnt here is that : "Binary Search can also be used to find max value of a monotonic function" .....
@kaustav07
@kaustav07 3 жыл бұрын
Kindly include painters partition too please.
@takeUforward
@takeUforward 3 жыл бұрын
Its same as allocation of minimum pages, exactly same problem..
@ashwinshetgaonkar6329
@ashwinshetgaonkar6329 3 жыл бұрын
intuition behind each step nicely explained.
@heyrmi
@heyrmi 3 жыл бұрын
there is a drastic improvement from video-1 of whiteboard. you are improving by each video.
@aadityabedi3140
@aadityabedi3140 3 жыл бұрын
Bhaiya thanks for this video and Tree series kab tab ayegi please bta do placements aane vali hai hamari
@cenacr007
@cenacr007 2 жыл бұрын
why is lowest possible distance 1 ? lowest possible should be when 2 cows are placed sided by side in the first 2 stalls with minimum values, but no body said the distance between first 2 stalls will be guaranteed 1, what if the array is 1 3 5 7 9, will we ever have a min distance 1 b/w 2 cows in such a case ? I think it should be arr[1] - arr[0] after sorting the array. Can somebody explain ?
@codetogether24x7
@codetogether24x7 2 жыл бұрын
same doubt bhai
@lakshsinghania
@lakshsinghania Жыл бұрын
yeah the search space will be more specifically low will be after sorting arr[1] - arr[0]
@rohitbagade9182
@rohitbagade9182 2 жыл бұрын
what if instead of 9 there is 12. now if we try for ans 4 c1 = 1 c2 = 8 c3 = 12 c1-c2 = 7 c2-c3 = 4 we can get ans for 4 , by evaluating c2-c3. if we only check c1-c2, then i guess we'll miss this testcase. (instead of 9, 12)
@stith_pragya
@stith_pragya Жыл бұрын
Thank You So Much Striver Brother............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@amanali9501
@amanali9501 2 жыл бұрын
at 14:02 why c1 and c2 is kept at 1 and 4 , it should be at 2 and 4
@SidNegi2511
@SidNegi2511 3 жыл бұрын
3:20 konse nashe h? How the hell difference of 2 and 4 is 6😢 and difference of 4 and 9 is 1
@takeUforward
@takeUforward 3 жыл бұрын
Slider corrected it..
@SidNegi2511
@SidNegi2511 3 жыл бұрын
@@takeUforward btw you explain things very well.. abhi tak 2 videos dekhi h lekin concepts bahut badhiya or clarity ke saath smjh aajate h..
@swapnanilgupta3046
@swapnanilgupta3046 Жыл бұрын
Great explanation. I understand that we have to be greedy and place the first cow always at the first position, but if after doing that we do not arrive at the solution, can no other solution exist if place the first cow at 2nd/3rd position and then try to place rest of the cows?
@nayanjha5670
@nayanjha5670 2 жыл бұрын
bhaiya is question me array jo milega wo sorted format me milega?
@PranavPrajapati-hd2eu
@PranavPrajapati-hd2eu Жыл бұрын
Gone through all other video on this question. But this one is amazing
@subhajeetchakraborty1791
@subhajeetchakraborty1791 2 жыл бұрын
Your excellent art of explaining these questions has inspired me to not lose hope and improve my problem solving skills further
@ayushjain9723
@ayushjain9723 2 жыл бұрын
One of the best explanation thanks Striver ! ❤❤
@meghnagupta3907
@meghnagupta3907 2 жыл бұрын
Vry nice explanation got every bit and learn something new. tysm
@baz2839
@baz2839 Жыл бұрын
to place cow at 1st position we need to sort array otherwise we wont get correct answer
@rajat7584
@rajat7584 3 жыл бұрын
Poori B.Tech nikal gayi par ye question ek baar me kabhi solve nahi hua 😂. Ab MS karte hue dekh raha hun. Thanks bro😀
@wisdomkhan
@wisdomkhan 2 жыл бұрын
Thanks to your previous videos, and intelligent ordering of questions in the SDE sheet, I did this on my own. Thanks bhai :)
@makaty9883
@makaty9883 Жыл бұрын
thank you striver, i really appreciate that man!!
@shivayvinaik7794
@shivayvinaik7794 2 жыл бұрын
amazing explanation mann!!!!!!!!!!!!!!!!! thank you so mucchhhh
@Finimals
@Finimals 2 жыл бұрын
This is a very good explanation
@cinime
@cinime 2 жыл бұрын
Understood! Super awesome explanation as always, thank you very much!!
@englishlnowledge486
@englishlnowledge486 2 жыл бұрын
For this question array must be sorted?
@rishabhgupta947
@rishabhgupta947 Жыл бұрын
Can someone explain why we are always assuming cow1 to be at index 0. At 19:30 mins in video co-ord = a[0] ? Can there not be any case when 1st cow is placed at any other index other than zero ?
@trysha2340
@trysha2340 Жыл бұрын
We need the best solution, thus the best solution is to place first cow in the first stall, and then from onwards we will get the best solution automatically.
@meetjoshi4521
@meetjoshi4521 Жыл бұрын
great explanation sir
@surajjadli1747
@surajjadli1747 3 жыл бұрын
Like the thumbnail simple 👌 just need to show front face.😄🏋🔥🔥🔥
@vamsipriya6204
@vamsipriya6204 2 жыл бұрын
Came here because of the binary search master class!
@radhikachaudhary2366
@radhikachaudhary2366 2 жыл бұрын
I have one doubt, you said if it's an unsorted array then sort it . Then after sorting ,the distance between the coordinates will change and perhaps answer will also change
@anshsrivastava8754
@anshsrivastava8754 2 жыл бұрын
Nobody gives a damn about your Doubts!
@saurabhahuja6707
@saurabhahuja6707 3 жыл бұрын
Possible combinations are 5c3 i.e 10
@GdLongerHandle
@GdLongerHandle 3 жыл бұрын
The energy 👀⚡⚡
@kunal_chand
@kunal_chand 3 жыл бұрын
Is this question a part of the SDE sheet, because I can't find it in any section. Anyway, Kudos to your efforts!
@takeUforward
@takeUforward 3 жыл бұрын
Binary search, please use the google doc version, and don't download it!! As I keep updating it..
@abhishekkumarsingh8603
@abhishekkumarsingh8603 3 жыл бұрын
@@takeUforward kuch ladke humare pehchan ke hardcopy nikaal ke highlighter chalate hai sde sheet pe unka kya kiya jaye😂
@manavshah7450
@manavshah7450 3 жыл бұрын
@@abhishekkumarsingh8603 hahaahahahaahahah
@aravakrishnaveni1801
@aravakrishnaveni1801 3 жыл бұрын
Your explanation is amazing sir
@scooby-doo7628
@scooby-doo7628 3 жыл бұрын
Hi, I know you are busy, recently i have gone through you segment tree with lazy propagation lecture, the concept u provide is amazing. Can you please make a video on persistent segment tree when you are free?
@vinod1922-n3v
@vinod1922-n3v Жыл бұрын
Thank you bhaiya. Great explanation
@soumikdutta7867
@soumikdutta7867 3 жыл бұрын
Bhaiya kaya explain kiya ho !!! Lit !! Love this explanation :-)
@RahulSingh-db3ge
@RahulSingh-db3ge 3 жыл бұрын
Tum bhut mst kaam krta hai striver bhai 🙂🙂.
@mohammadumaidansari5087
@mohammadumaidansari5087 3 жыл бұрын
Another best one from the best 👍💯
@nileshsinha7869
@nileshsinha7869 3 жыл бұрын
Understood ❤❤ Great Explanation ..keep this coming
@dudamneerajdattu1459
@dudamneerajdattu1459 Жыл бұрын
today's codestudio's moderate difficulty problem, and i understood the approach but somewhere I am struggling to code
@hassanmohammed904
@hassanmohammed904 2 жыл бұрын
Why does the first cow have to be at the left extreme?
@rishabhgupta9846
@rishabhgupta9846 Жыл бұрын
After getting initial intuition able to solve by myself,thanks striver
@sakshamsrivastava6280
@sakshamsrivastava6280 3 жыл бұрын
great explaination.Thankyou for providing this
@yashipathak6184
@yashipathak6184 2 жыл бұрын
THANK YOU!!
@chaitanyakumar9229
@chaitanyakumar9229 3 жыл бұрын
similar to arrange books -> which are all based on painters partition alogo 😁👍
@srushtinarnaware4919
@srushtinarnaware4919 Жыл бұрын
thankyou
@siddharthupadhyay4246
@siddharthupadhyay4246 2 жыл бұрын
Thank you sir, great explanation
@shantanumapari6679
@shantanumapari6679 2 жыл бұрын
very lucidly explained!!
@chayanjain6902
@chayanjain6902 3 жыл бұрын
Sir when will stack and queue solutions will come?
@MJ-dq8om
@MJ-dq8om 3 жыл бұрын
Nice explanation
@sankalpjain4841
@sankalpjain4841 3 жыл бұрын
Please, can anyone explain, why to take low=1, instead of low=xi[1]-xi[0] in binary search approach. ThankYou in advance
@naveensingh2658
@naveensingh2658 2 жыл бұрын
1 will be the lowest possible minimum distance.
@cenacr007
@cenacr007 2 жыл бұрын
​@@naveensingh2658 why, lowest possible should be when 2 cows are placed sided by side in the first 2 stalls with minimum values, but no body said the distance between first 2 stalls will be guaranteed 1, what if the array is 1 3 5 7 9, will we ever have a min distance b/w 2 cows in such a case ? I think it should be arr[1] - arr[0] after sorting the array.
@arnavagrawal3499
@arnavagrawal3499 2 жыл бұрын
@@cenacr007 No actually there could be a case for ex. - 3 6 9 10 11 13 where we need to place 6 cows then min possible would be 1 in that case so in my opinion it should be actually min(arr[i + 1], arr[i]) for i = 0 till size - 2 index (in this case till 4th index) but it doesn't matter even if we take 1 as the minimum because the final answer will only give the maximum possible minimum distance.
@amanbhadani8840
@amanbhadani8840 2 жыл бұрын
More accurately i say low is the minimum value among all the consecutive differences of elements.
@012akashh
@012akashh 3 жыл бұрын
You are superb buddy ..so hard working where do you get this inspiration from ? Just finished looking the last video and new one is ready 😊
@arint725
@arint725 2 жыл бұрын
similar to book allocation problem
@Ankit.yt_885
@Ankit.yt_885 2 жыл бұрын
Very Nicely Explained :)
@sketchwithbratati4397
@sketchwithbratati4397 3 жыл бұрын
Amazing explanation striver❤️👍🏻
@satyamchoudhary2573
@satyamchoudhary2573 Жыл бұрын
legend of explaination
@adarshrai9516
@adarshrai9516 3 жыл бұрын
Bhai dheere dheere aap mere clg me famous ho rahe ho.Kaafi log abhi takeuforword channel se prep kar rahe.Sab din me ek baar puchhte hai SDE sheet ka kitna questions kiya bhai tune😂😂
@takeUforward
@takeUforward 3 жыл бұрын
Haha, dabakar share karo :P
@devkumaracharyaiitbombay5341
@devkumaracharyaiitbombay5341 Жыл бұрын
bhai mind blowing your efforts in this video make my dsa journey easy love you so much bro. keep making this type of video in **WHITE BOARD
@sidharthjain7229
@sidharthjain7229 2 жыл бұрын
Sir why are we always picking the first position as optimal in the canPlaceCows function?
@aditya-st1sv
@aditya-st1sv 3 жыл бұрын
Striver superstar🤩
@youngshahrukhkhan8179
@youngshahrukhkhan8179 3 жыл бұрын
Awesome Explanation
@subratarajak8391
@subratarajak8391 3 жыл бұрын
Another masterpiece... ❤from CGEC bhaiya
@harshavardhanbashavathini6534
@harshavardhanbashavathini6534 2 жыл бұрын
I did not understand, taking arr[0] for the first cow.(Greedy Approach). Please explain
@heyrmi
@heyrmi 3 жыл бұрын
Bhaiya it would be great if you can also tell the companies in which the questions are asked. Many of us don't even have a clue of frequency and company in which questions are mostly asked. It helps a lot
@takeUforward
@takeUforward 3 жыл бұрын
Sde sheet for that.
@arihantjha7062
@arihantjha7062 3 жыл бұрын
I don't understand, why the first cow always has to be plased at the first given co-ordinate?
@chhatrapathisivajilakkimse8108
@chhatrapathisivajilakkimse8108 2 жыл бұрын
Exactly ! that's where I'm stuck . Like there could be other combination from the list which might get possible for given mid . Please can anyone explain this
@kavitgangar2510
@kavitgangar2510 2 жыл бұрын
Because we want to know whether we can place the cows at a min distance of 'dist'. So, if by placing the cow at the first co-ordinate, we cannot get a configuration where the dist between consecutive cows is >= dist, then by placing the first cow at any other position as well we wont get any configuration
@nayankhanna2367
@nayankhanna2367 3 жыл бұрын
Great explanation!
@SatyamKumar-bw4vi
@SatyamKumar-bw4vi 2 жыл бұрын
Hare Krishna ! Bhaiya
BS-17. Aggressive Cows | Binary Search Hard
26:44
take U forward
Рет қаралды 176 М.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
Queue Implementation using Arrays
13:46
take U forward
Рет қаралды 133 М.
Median of Row Wise Sorted Matrix | Nested Binary Search
28:42
take U forward
Рет қаралды 138 М.
BS-16. Kth Missing Positive Number | Maths + Binary Search
22:52
take U forward
Рет қаралды 159 М.
Winning Google Kickstart Round A 2020 + Facecam
17:10
William Lin (tmwilliamlin168)
Рет қаралды 10 МЛН
Quicksort: Partitioning an array
4:48
KC Ang
Рет қаралды 592 М.
BS-18. Allocate Books or Book Allocation | Hard Binary Search
27:29
take U forward
Рет қаралды 184 М.
The Best Way to Learn Linux
9:45
Mental Outlaw
Рет қаралды 130 М.