Lecture 15: Book Allocation Problem || Aggressive Cows Problem || Binary Search Advanced Problems

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 1.4K

  • @CodeHelp
    @CodeHelp  2 ปีที่แล้ว +123

    Do Visit Relevel: relvl.co/cu68

    • @gagankhatri3312
      @gagankhatri3312 2 ปีที่แล้ว +3

      Bhaiya ek Excel Sheet bna do ussme notes daal diya karo Wo better hoga

    • @noobprogrammer3040
      @noobprogrammer3040 2 ปีที่แล้ว +5

      Bhaiya videos ki frequency alternate days ki kardo taaki ham content ko digest kar paaye and isse aap aur bhi achee se videos ko bna paoge. 🥺🥺 DSA course bhot sahi jaara hai aapka

    • @gagankhatri3312
      @gagankhatri3312 2 ปีที่แล้ว

      @@noobprogrammer3040 Nhi Yaar, Bhaiya Daily hi aane do (agar video mein der ho toh koi nhi baaki Daily hi sahi Hai)

    • @gagankhatri3312
      @gagankhatri3312 2 ปีที่แล้ว

      @@noobprogrammer3040 Agar aapko do din mein ek karni hai toh ek karo yaar , course ko acche se chalne do

    • @rishitarora321
      @rishitarora321 2 ปีที่แล้ว +1

      @@gagankhatri3312 bhai dsa ke elawa bhi bahut kaam hote hai clg ke karne ko side hustle, cgpa mantain, core subject padhna, handle final exam, alternate days hoga toh content samjhne ka time milega.
      Iss speed se chale toh course katam ho jaega par command nhi banegi coding mein.

  • @narendrarokkam5367
    @narendrarokkam5367 2 ปีที่แล้ว +934

    Only below middle class people and tier 3 clg people know the value of this course love from Andhra Pradesh bhaiya

    • @mr.subhajit9444
      @mr.subhajit9444 2 ปีที่แล้ว +26

      You are right bro

    • @ritikpatidar4331
      @ritikpatidar4331 2 ปีที่แล้ว +79

      Bhai tier 1 or 2 me bhi proff ganta kuch na padhte 🤣🤣

    • @aryannautiyal6926
      @aryannautiyal6926 2 ปีที่แล้ว +53

      @@ritikpatidar4331 i am tier 1 college and i can confirm that proffesor will not help you in placement its your hardwork and skill which matters the most

    • @ritikpatidar4331
      @ritikpatidar4331 2 ปีที่แล้ว +6

      @@aryannautiyal6926 bhaiya aap to personally le liye yr hum humare proff k liye bole the 😐

    • @peterpace3379
      @peterpace3379 2 ปีที่แล้ว

      @@ritikpatidar4331 Unn chutiyo ko khud ko kuch nahi aata, kya padhaenge woh hume

  • @chetanpatil9411
    @chetanpatil9411 ปีที่แล้ว +34

    Love Babbar bhai is doing a fabulous job. No playlist no channel on youtube teaches problem solving like this. This is much better than paid courses or other youtube views where unwanted unnecessary graphics are used rather than providing pure knowledge of logic building and thinking process. So proud of you Love Babbar Sir.

  • @shresthsharma6922
    @shresthsharma6922 2 ปีที่แล้ว +51

    Bhaiya you're just unbelievable , I mean from SSB TO SDE and now to one of the finest teachers of DSA I have ever come across. Huge Respect Bhaiya.🙏👌❤️

    • @abhaypandey8325
      @abhaypandey8325 11 หลายเดือนก่อน

      ssb? nda/cds?

    • @newhope5729
      @newhope5729 11 หลายเดือนก่อน

      @@abhaypandey8325 Yeah NDA it is

    • @newhope5729
      @newhope5729 9 หลายเดือนก่อน

      @Vishal__Autade Yeah

  • @human75788
    @human75788 2 ปีที่แล้ว +98

    The confidence I gained after watching your lectures thoroughly and solving problems myself is just everything I wanted. God bless you, Sir and thanks again.

    • @anuragrana6253
      @anuragrana6253 ปีที่แล้ว +1

      aap problem kaha se solve karte ho ,i mean from wich book?

    • @ashishdhal4614
      @ashishdhal4614 ปีที่แล้ว

      .

  • @anuragpandey8165
    @anuragpandey8165 2 ปีที่แล้ว +144

    Trust me, I have seen so many videos on the famous "Book Allocation Problem" and I could not find better explanation than this. This is definitely the best DSA course available anywhere.

    • @justarandomguy6106
      @justarandomguy6106 2 ปีที่แล้ว +7

      What about striver's explanation

    • @dhhforlife8889
      @dhhforlife8889 2 ปีที่แล้ว +17

      @@justarandomguy6106 There is a difference between better explanation and better solution. Hope you understand.

    • @rameshmalhotra9525
      @rameshmalhotra9525 2 ปีที่แล้ว

      th-cam.com/video/eWFrau_sE34/w-d-xo.html

    • @alexrcrew1975
      @alexrcrew1975 2 ปีที่แล้ว +11

      @@justarandomguy6106 he sounds too professional and we dont want that we want desi explanation

    • @dheerajsharma1787
      @dheerajsharma1787 2 ปีที่แล้ว +4

      @@alexrcrew1975 sahi pakde hain.

  • @MagicianSaransh
    @MagicianSaransh 2 ปีที่แล้ว +28

    This guy understands what we have understood and what not . That is a skill of a brilliant teacher . Great work

  • @_Princechauhan
    @_Princechauhan 10 หลายเดือนก่อน +5

    in BOOK ALLOCATION PROBLEM.
    there is a case missing : where number of books is less than the number of student so we need to add another condition in the start of our program (after defining mid || before while loop ) to check this condition.
    if(n

    • @aryyann05
      @aryyann05 13 วันที่ผ่านมา +1

      if you look at the constraints, it says than 2

  • @harshmedhavi2509
    @harshmedhavi2509 2 ปีที่แล้ว +53

    Thanks bhaiya, I have started gaining a bit of confidence because of you. Please continue this series till the very end, loving it bhaiya! We all are here, and we all are here till the very end! No going back 🔥🔥🔥

  • @prabhat1758
    @prabhat1758 2 ปีที่แล้ว +11

    Best thing is that you know which part we will find difficult to understand and rather than telling us to just re-watch it you take the effort to explain it again with more minute details.

  • @csechandanmohanty
    @csechandanmohanty 2 ปีที่แล้ว +86

    In Book Allocation question you have missed that no of students cant be greater then no of Books i.e
    if( M > N) --> return -1;

    • @bhaskarkharate2364
      @bhaskarkharate2364 ปีที่แล้ว +6

      check constraints.

    • @jaiprakashgupta9868
      @jaiprakashgupta9868 ปีที่แล้ว

      I also saw this edge case on gfg but then I checked the constraints.....on codestudio it is given M

    • @UECAshutoshKumar
      @UECAshutoshKumar ปีที่แล้ว +5

      Yes this is an edge case which has been overlooked.

    • @jyotirmayapatra6967
      @jyotirmayapatra6967 5 หลายเดือนก่อน +2

      Bhai mera bohat der se issue aa rha tha .... aur main bewakoof log main galti dhund rha tha
      ...thanks bhai

    • @Haneesha009
      @Haneesha009 3 หลายเดือนก่อน

      where should i write this

  • @lalitbisht8381
    @lalitbisht8381 ปีที่แล้ว +27

    Bhut bhut bhut jyada difficult but after 4Days watching it constantly now it feels easy😂

  • @hitsharnam3177
    @hitsharnam3177 2 ปีที่แล้ว +197

    Those who cannot afford expensive course like Coding Ninjas's knows the true value of this course.

    • @MegaGreatape
      @MegaGreatape 2 ปีที่แล้ว +17

      Coding Ninjas course isn't something very much helpful. I have taken them and I know.

    • @PrinceSingh-kk2yx
      @PrinceSingh-kk2yx 2 ปีที่แล้ว +13

      Telegram pe sav free milta hai🤣🤣

    • @lavishtripathi4380
      @lavishtripathi4380 2 ปีที่แล้ว +4

      @@PrinceSingh-kk2yx ya true sab hai waha pe 😂😂😂

    • @hitsharnam3177
      @hitsharnam3177 2 ปีที่แล้ว +7

      @@PrinceSingh-kk2yx complete nhi milta kahi... Assignment b important hoti h... Complete course mila tjhe kahi...Link share kr de telegram gp ka

    • @hitsharnam3177
      @hitsharnam3177 2 ปีที่แล้ว

      @@PrinceSingh-kk2yx Abe rehne de bakchod....yahan kya karne aaya h fir 🤣🤣. Jaake apne courses kr dobara telegram vale

  • @kingcrayon195
    @kingcrayon195 2 ปีที่แล้ว +23

    Aj Dusra din hai jab mai ye problems fir sa dekh raha hu..... Kal laga tha Mersa Na ho payega...But ajj Kuch Kuch samaj ayya.... Placement tow lekar hi rahenga

    • @dhruvsrivastava4094
      @dhruvsrivastava4094 2 หลายเดือนก่อน +1

      you got placement .Genuinely asking

  • @kaushikmandal8061
    @kaushikmandal8061 2 ปีที่แล้ว +28

    you can add another test case and that is, what if the number of students are greater then the length of the array?
    eg: Arr[] = {10,20,30,40, 50}; and m = 12.
    In this case the code will fail. So to avoid this, we can write a simple if statement in the beginning of the code/function.
    i.e.,
    if(m > Arr.length){
    return -1;
    }

    • @094_sujithkumar4
      @094_sujithkumar4 ปีที่แล้ว +1

      it is not a possible test case ..please check constraints

    • @createop1689
      @createop1689 ปีที่แล้ว +5

      @@094_sujithkumar4 actually it is . the question is updated and the new test case was
      5 6
      2 8 8 4 5
      where 5 is the size of array or elements present in array and 6 is the number of students. according to question we need give books to each and every child so there are 6 students but books are like 5 . so in this case we need to return -1;

    • @dankfr1198
      @dankfr1198 ปีที่แล้ว +1

      @@createop1689 IKR I was so confused and then saw your comment! you guys are amazing :)

    • @harshkharniwal317
      @harshkharniwal317 10 หลายเดือนก่อน

      This test case got me too, but i understand it right away and solved it, then came to comment section to see if someone else also mentioned it or not.

    • @anirudhrana5578
      @anirudhrana5578 5 หลายเดือนก่อน

      Are thanks bhai

  • @andyy5201
    @andyy5201 2 ปีที่แล้ว +18

    Honestly vaiya.... 1 hour se error solve krte krte jab last mai green ticks dikhta hai ... Alag hi satisfaction ata hai.... Love it ❤💝

  • @rahulsil3827
    @rahulsil3827 2 ปีที่แล้ว +12

    The book allocation problem is now crystal clear to me, the approach and all were very clearly explained. ❤️

  • @harshitsaxena6075
    @harshitsaxena6075 2 ปีที่แล้ว +6

    Couldn't find any other video on TH-cam who can explain like this...Excellent

  • @cuteanime2
    @cuteanime2 2 ปีที่แล้ว +45

    This series is just amazing , and these three questions were like bomb. It took me 6 hours to understand and complete this video. but in the end it was worth watching. keep rocking . keep growing.

  • @zoya5034
    @zoya5034 2 ปีที่แล้ว +6

    When I try to solve sir, logic is not building, I think I m the only one, jisko phr b clearly samaj nhi ara.. Aap to itna acha smjate ho sir.. Love u❤ please sir help me.. 🙏😭 GOD BLESS UU sirji..

  • @ecoboy7829
    @ecoboy7829 ปีที่แล้ว +5

    Honestly for the aggressive cow prblm it was so overwhelming initially to understand the soln but after giving a little thought I realised how beautiful was the idea of soln. Awesome man....

  • @Ankit.yt_885
    @Ankit.yt_885 2 ปีที่แล้ว +6

    Literally the best explanation of the Book Allocation problem on TH-cam. Clean and easy to understand code. Well Done! :)

  • @AmanKumar-xw5bs
    @AmanKumar-xw5bs ปีที่แล้ว +8

    In the aggressive cows question, as we are already sorting the array , we can just find the value of e as e=stalls[n-1]-stalls[[0],no need of loop right.

    • @aditya_jaiswal.
      @aditya_jaiswal. ปีที่แล้ว

      Actually intially Babar bhaiya didn't sorted the array that's why he did that part to get maxi value for e and ultimately after sorting array he forgot😅 to do e=stalls[n-1] - stalls[0].but it will work also. So no need to worry 😊

  • @uzairshaikh3478
    @uzairshaikh3478 ปีที่แล้ว +1

    Meko video dekhte dekhte feel hua ye cheez ...ek cheez ko 3 4 baar explain kardete ho such me ...jitna thank u bolu aapko kam hi rahega zindagi bhar ...❤️ Allaha aapko khush rakhe aur kamiyabi de

  • @ritankjaikar008
    @ritankjaikar008 ปีที่แล้ว +7

    In book allocation problem: Test case Books: [1,2,3,4] and Students:5. Then I guess ans will be wrong. It should return -1 as number of students are more than number of books, and condition says each student gets at least 1 book.
    Solution: Just put this code in starting:-
    if(n

  • @rishabhrajdhiman3005
    @rishabhrajdhiman3005 2 ปีที่แล้ว +5

    I got goosebumps after solving EKO problem , never felt that much thrill in coding

    • @AbhishekSharma-tm2ko
      @AbhishekSharma-tm2ko 2 ปีที่แล้ว

      #include
      using namespace std;
      long long int checkSum(long long int numTree[], long long int N, long long int M,long long int mid){
      long long int sumWood = 0;
      for(long long int i = 0; i N >> M;
      for(long long int i =0; i> numTree[i];
      }
      cout

    • @AbhishekSharma-tm2ko
      @AbhishekSharma-tm2ko 2 ปีที่แล้ว +2

      bro...my testcases are running correctly, but when i am going to submit my code on spoj, it's giving error. Can you share your code?

  • @saunakrath4816
    @saunakrath4816 2 ปีที่แล้ว +7

    Thnx Guruji!!! This Course and your Teaching Skills, both are at next level.

  • @naimishrishu3255
    @naimishrishu3255 ปีที่แล้ว +4

    You solved the biggest question of "DSA kaha se karu" all my friends follow you
    😃

  • @debaditya3609
    @debaditya3609 2 ปีที่แล้ว +51

    43:36 PAINTER'S PARTITION PROBLEM SOL
    bool isPossibleSol(vector &boards, int n, int k, int mid){
    int painter = 1;
    int boardsPainted = 0;

    for(int i = 0; i mid){
    return false;
    }
    boardsPainted = boards[i];
    }
    }
    return true;
    }
    int findLargestMinDistance(vector &boards, int k)
    {
    int s = 0;
    int sum = 0;
    int n = boards.size();
    for(int i = 0; i

    • @user-ut6gm7hv2k
      @user-ut6gm7hv2k ปีที่แล้ว +1

      i am beginer but cant understand easily

    • @theknowingeye5998
      @theknowingeye5998 ปีที่แล้ว +3

      @@user-ut6gm7hv2k get good scrub

    • @HuzaifaKhan-iy5qj
      @HuzaifaKhan-iy5qj 9 หลายเดือนก่อน +2

      It will stuck at 9 and will jump for third painter.

  • @dipawalimandaokar3820
    @dipawalimandaokar3820 ปีที่แล้ว +3

    This is just awesome bhaiya . Before seeing this video i thought that binary search is used for only searching elements in array . But now I understood how we can solve many amazing problems using this approach. And the way you teach is just so easy to understand . Thank you for creating such gem content on you tube for free. 😊

  • @taansssss
    @taansssss 4 หลายเดือนก่อน +1

    been trying to start dsa from 3 years never understood how to these videos really helped me move forward

  • @Wanna_be_01
    @Wanna_be_01 2 ปีที่แล้ว +7

    43:27 HomeWork
    -------------------------------------------------------------------
    Painter's Partition Problem
    -------------------------------------------------------------------
    bool isPossible(vector &boards, int k, int mid){
    int painters = 1;
    int blocks = 0;

    for(int i=0;i mid){
    return false;
    }
    blocks = boards[i];
    }
    }
    return true;
    }
    int findLargestMinDistance(vector &boards, int k){
    int s = 0;
    int sum = 0;

    for(int i=0;i

  • @Shivamkumar-xu6hu
    @Shivamkumar-xu6hu 2 ปีที่แล้ว +15

    One suggestion tell the brute force approach first with TC then do optimization..
    Rest is 🔥🔥

  • @kaustavkarak4875
    @kaustavkarak4875 8 หลายเดือนก่อน +9

    In Allocate Books:
    if(m>n){
    return -1;
    }
    This should be the first line of code in the function allocateBooks( ). This is an edge case which has been missed. The number of students can't be greater than the number of books.

    • @meetmakwana3427
      @meetmakwana3427 8 หลายเดือนก่อน +1

      Yes bro you are right. Thanks. @CodeHelp please pin this comment

    • @priyanshukumarsah2746
      @priyanshukumarsah2746 3 หลายเดือนก่อน +1

      thanks brother , I have been thinking that why my test cases are not passing now i got the answer.

    • @khushigupta1783
      @khushigupta1783 2 หลายเดือนก่อน

      @@priyanshukumarsah2746 can u send the whole code as my test cases r not getting passed

  • @yp_016
    @yp_016 ปีที่แล้ว +2

    thank u so much bhaiya . confidence badhta hi ja raha haii., every q. ko itne deep me samjah rahe ho maja aa gaya .
    thank u so much for this series 😇. AB KUCH KARKE HI JAYENGE .
    EVERYONE CLAPING FOR LOVE BABBAR 👏

  • @yashsoni9197
    @yashsoni9197 2 ปีที่แล้ว +4

    Once I used to scare from these concepts and now i am here to convert that fear into my strength....so far so good

    • @leoved1073
      @leoved1073 2 ปีที่แล้ว

      Hey bro, how far you complete the course???

  • @mdks57
    @mdks57 6 หลายเดือนก่อน +1

    In book allocation problem you missed if(m>n) {return -1;}

  • @avneet12284
    @avneet12284 2 ปีที่แล้ว +3

    Watched the aggressive cows question after trying out many videos. No success till I watched this one. Superb explanation, bro.

  • @abhinavkumaryadav7507
    @abhinavkumaryadav7507 หลายเดือนก่อน +2

    Q) PAINTERS PROBLEM (simple changes and it ran)
    bool ispossible(vector &boards,int m , int mid)
    {
    int stud=1;
    int pagesum=0;
    for (int i = 0; i < boards.size(); i++)
    {
    if (pagesum+boards[i]m || boards[i]>mid )
    {
    return false;

    }

    pagesum=boards[i];
    }

    }
    return true;
    }
    int findLargestMinDistance(vector &boards, int k)
    {

    int start=0;
    int sum=0;
    int ans=0;
    for (int i = 0; i < boards.size(); i++)
    {
    sum=sum+boards[i];
    }
    int end=sum;
    int mid=start+(end-start)/2;
    while(start

  • @Aniket-my6gl
    @Aniket-my6gl ปีที่แล้ว +12

    Aggressive COWS can really make you aggressive 💀..

  • @ankandas596
    @ankandas596 8 หลายเดือนก่อน +1

    In the Book Allocation prblem--
    Do this above the while function
    If(m>n){
    return -1;
    }

  • @hirdyanshsharma4349
    @hirdyanshsharma4349 ปีที่แล้ว +3

    bhaiya last 7 din yeh video bar bar dekh raha hun aur question solve kar raha hun, ab ja ke yeh question solve hue aur samaj aye hai😂. Awesome video bhaiya👌👌

    • @ababakr_asa
      @ababakr_asa หลายเดือนก่อน

      Abb DSA me kaha ho bro

  • @deepnarayan1281
    @deepnarayan1281 9 หลายเดือนก่อน +2

    Finally, someone explained these questions Easily.

  • @adityasinha8308
    @adityasinha8308 2 ปีที่แล้ว +12

    Hi, video is awesome, thanks for it...best part is when you gave explanation at 51:00 that why you put this logic which help viewers like us to get the exact reason to apply this method...
    One suggestion, though it is upto you , I would like to request either put videos alternate day or decrease the length of video to 30-40 minutes because people like me take our own sweet time to understand and implement. Please if you can consider this for starting phase and once we start building logic and understand as video progresses you can put the video as per your choice.

  • @saitanush9453
    @saitanush9453 2 ปีที่แล้ว +2

    Tq bhaiya😄😄😄, Bhaiya ab thak ka first video hai jaha dimaag ka dahi hua , abhi bhi isPossible ka function mein doubt hai, 2 baar dekh chuka hu video, fir dekunga😄, DSA ko crack karna hai bas, pura motivation toh apne diya hai

  • @khushboobuwade2932
    @khushboobuwade2932 2 ปีที่แล้ว +3

    Content of this lectures is much more better than any other courses .. thanks alot

  • @mayanksingh68
    @mayanksingh68 2 ปีที่แล้ว +1

    just add in binary search function
    if(n

  • @LivewithPawan
    @LivewithPawan ปีที่แล้ว +3

    allocate book problem me ek condition or hai agr number of student (m) > book(n) so return -1 becoz us case me 1 student remain rh jayegaa jisko koi book nhi milegi and this is out of condition
    bool ispossible(vector arr, int n, int m , int mid)
    {
    int studentcount = 1;
    int pagesum = 0;
    for(int i = 0; i mid)
    {
    return false;
    }

    pagesum = arr[i];
    }
    }
    return true;
    }
    int findPages(vector arr, int n, int m) {
    int s = 0;
    int sum = 0;

    for(int i = 0; in)
    {
    return -1;
    }
    int e = sum;
    int ans = -1;
    int mid = s + (e-s)/2;
    while(s

  • @prashantchauhan6591
    @prashantchauhan6591 ปีที่แล้ว +2

    Greate Content, first time ever i'm able to solve mid and hard programming questions with full understanding without seeing any sol. Big thanks Bhaiya :)

  • @ijunedaslam
    @ijunedaslam ปีที่แล้ว +3

    36:24 - Painter’s Partition Problem
    43:24 - Homework
    bool isPossible(vector &boards,int k,int mid,int n){
    int painter=1;
    int sum=0;
    for(int i=0;imid) return false;
    sum=sum+boards[i];
    if(sum>mid){
    painter++;
    sum=boards[i];
    }
    }
    return painter

  • @Codewithkumar-gc1kr
    @Codewithkumar-gc1kr 3 หลายเดือนก่อน +1

    I have started learning DSA from code-help. It is really very worthful course ❤. Only tier 3 college students know the value of this course ❤❤

  • @subhasishasahoo.105
    @subhasishasahoo.105 2 ปีที่แล้ว +11

    Present bro....
    I am waiting for the lectures ...
    Bro your are in the next level.......

  • @fitwithvish
    @fitwithvish ปีที่แล้ว +1

    add a base case also in book allocation problem without base case it show error in 2 test case
    if(n

  • @Sita-Ram-ji
    @Sita-Ram-ji ปีที่แล้ว +3

    I have certain courses of DSA like: 1: Complete Interview Preparation course from GFG and 2: Mastering Data Structures & Algorithms from Abdul Bari... But Still I am studying from your course because your way of explanation... Thank you so much bhaiya for this beautiful and wonderful course....
    Love You... Gulabi Dil... Gulabi Dil...

  • @iamrey192
    @iamrey192 ปีที่แล้ว +1

    i gave more than 1 week on these problems but deeply understood the concept. thanks bhaiya,.

  • @sjcreations2490
    @sjcreations2490 2 ปีที่แล้ว +5

    nice problems. now i am felling confident during solving questions after following this series..

  • @MohitSaini-ct4vt
    @MohitSaini-ct4vt 4 วันที่ผ่านมา

    The edge case if(n

  • @preetkatiyar969
    @preetkatiyar969 2 ปีที่แล้ว +3

    i watch 3 times now i understand this wonderful concept. Thanks

  • @PrakharRastogi-o2e
    @PrakharRastogi-o2e 11 หลายเดือนก่อน +1

    In the `Aggressive cows` inside the `isPossible()`, start the for loop from 👉 `i= 1` not from 0, because, 0 is already covered, by 1st cow,
    this will make the code faster to `13 ms` 🚀 rather than `18 ms` try this.

  • @sigmapiebonds3191
    @sigmapiebonds3191 2 ปีที่แล้ว +4

    Understood the algo's soo well!! But was a bit different for aggresive cows problem but no worry got the concept well!!😊

  • @vidhusrivarenya5138
    @vidhusrivarenya5138 11 หลายเดือนก่อน +2

    00:00 Learn how to solve the Book Allocation Problem using binary search
    11:14 Binary search used to find square root of an integer
    21:50 Binary search algorithm used to find possible solution for book allocation
    31:29 Two problems discussed: Book Allocation and Painter's Partition Problem
    38:38 Assign cows to stalls with minimum distance between them
    44:45 Find largest minimum distance between two cows using binary search
    51:42 Binary search is applied to find the largest minimum distance between two cows in a given array of stalls.
    58:23 Learned binary search and solved dynamic programming problems

  • @betchabbh1075
    @betchabbh1075 2 ปีที่แล้ว +3

    everyday i feel excited to watch ur videos and learn new stuff and that kindof josh has only come because of u bro thanks a lot for providing us with the best and working so hard !

  • @satvikchauhan85
    @satvikchauhan85 11 หลายเดือนก่อน +1

    Really amazing video
    Just a mini correction
    56:17 it would be s>e

  • @web3global
    @web3global 2 ปีที่แล้ว +16

    Loving it sir, regularly watching every lecture! 📈
    Fees motived everyday 🚀
    Sir, how many lectures do the whole course will have, just a rough estimate?

    • @delta_mohit
      @delta_mohit ปีที่แล้ว

      140

    • @mkat21
      @mkat21 ปีที่แล้ว

      @@delta_mohit waaaah course khtm hone ke baad bat rha.nice

  • @AbhishekRajput-bc6ux
    @AbhishekRajput-bc6ux 2 ปีที่แล้ว +3

    Best DSA Course.
    Grate Explanation of each topic and Question.

  • @coderslanguages4003
    @coderslanguages4003 ปีที่แล้ว +1

    great sir you are doing a very good work for everyone student who is suffering to solve coding problems you teach like actually you are in front of me telling everything in detail ,
    thank you so much.

  • @deepaksolanki1972
    @deepaksolanki1972 2 ปีที่แล้ว +10

    For Aggressive Cows : similar logic code in Java gives TLE. It seems like bug in CodingStudio

    • @faltuaadmi6424
      @faltuaadmi6424 ปีที่แล้ว +2

      Mera to ye book allocation wale me bhi TLE aagaya code studio pr, any suggestion?

    • @deepakkansal9112
      @deepakkansal9112 ปีที่แล้ว +1

      @@faltuaadmi6424 mid ko update krna bhul gya hoga

  • @therealartist9
    @therealartist9 8 หลายเดือนก่อน +1

    watched the video by reversing it 2 to 3 time and now finally understood the concept . But it need carefull revision practice .

  • @knowledge_Creditors
    @knowledge_Creditors ปีที่แล้ว +6

    NO CODER IS BEST THAN "BUBBAR" AND NO COURSE IS BETTER THAN WHAT HE TEACHING .
    "Salute you My Sir "
    🙌

  • @pomhae
    @pomhae 11 หลายเดือนก่อน +1

    in aggressive cows problem, how did you know that subtracting MAXI from MINI will give us the maximum number and not by adding the elements of the array

  • @YP-vb9bs
    @YP-vb9bs 2 ปีที่แล้ว +3

    Thankyou So Much Bhaiya for this Wonderful 😊 Course.Please keep it Complete series.Waiting for next lectures 🥰.

  • @ArpitKumar-yo6up
    @ArpitKumar-yo6up ปีที่แล้ว +1

    The testcases in codestudios are not appropriate, it doesn't has a testcase if the number of students are greater than the number of books

  • @saketsrivastava1424
    @saketsrivastava1424 2 ปีที่แล้ว +4

    Thank you for the course Bhaiya
    Awesome couse ever

  • @MohanSingh-rj3td
    @MohanSingh-rj3td 2 ปีที่แล้ว +1

    i cant believe how you make such a beautiful lecture using tough question like book allocation and aggressive cow.
    coding is beautiful with you bhaiya thanks

  • @anuragtiwari4182
    @anuragtiwari4182 2 ปีที่แล้ว +3

    59:01 end ko mid - 1 kyu karre hai....if wo mid pe ni possible hai toh usse kam pe kaise hoga ??? lease help me!

  • @electro1146
    @electro1146 2 ปีที่แล้ว +1

    cheezein 65-70% samaj mein aain hein. wapas dekh lunga aur clear ho jayega.

  • @vaibhavshinde5520
    @vaibhavshinde5520 2 ปีที่แล้ว +3

    Why dont we just find min and max value in array of aggressive cows and return their subtraction alone...we dont have to worry about their indices. We need only distance...I think this way it'll be more optimized O(n)..by binary search approach we only increasing the complexity by sorting the array O(nlogn) first...

    • @sidh8302
      @sidh8302 2 ปีที่แล้ว

      where you gonna put the other cows then ?

    • @krishsachdeva1105
      @krishsachdeva1105 ปีที่แล้ว +1

      Mere bhai cows ka no. 2 se jayda hua toh kyA KArega

  • @arihantkapoor4349
    @arihantkapoor4349 ปีที่แล้ว

    at 31:00, the condition n

  • @DurgaShiva7574
    @DurgaShiva7574 2 ปีที่แล้ว +4

    thankyou.. this is the best thing i have ever seen, one doubt, will this solution work if, all the students are NOT allocated books, because, we checked for studentCount < m, but , after exiting the for loop in the isPossibleSolution function , we never checked for studentCount == m , shouldnt this be added in the code?... Love bhai, please let me know for this scenario

    • @sonicboom6635
      @sonicboom6635 2 ปีที่แล้ว

      @Divyansh Gupta Hello bro did you found out solution for this point??

    • @md_asharaf
      @md_asharaf 2 ปีที่แล้ว +1

      actually we checked for studentcount > m, if it is true it means you have allocated a bit lower no. of pages to students therefore some books are still not allocated hence you are required more students to allocate remaining books to them and if you are not able to allocate half of the sum of pages to a student for allocation of the all books then how would you allocate less than that no. of pages(why less than??because we have to return minimum no. of pages)to a student for allocation of all books ?? so it can not be a possible solution, if it is not true then there is a value of studentcount

  • @ankitchaturvedi2941
    @ankitchaturvedi2941 ปีที่แล้ว +1

    In last question of cows,
    We can directly minus the last and first position of vector
    After sorting
    As min distance is at a[0] and large at a[n]
    Then why did we go to binary search

  • @parthdeshwal4419
    @parthdeshwal4419 7 หลายเดือนก่อน +3

    this might be the toughest lecture i have watched since i started coding(6 months back). am i the only dumb person here?

    • @Josuke217
      @Josuke217 6 หลายเดือนก่อน

      These are FAANG M interview level questions (advanced binary search questions). You have only been coding for 6 ( now 7) months so don't get overwhelmed. Try doing some easy BS questions and try understanding other programmers' codes.

    • @priyanshubari9685
      @priyanshubari9685 3 หลายเดือนก่อน +2

      no, these are seriously challenging questions. i have done decent amount of coding and im finding it really difficul.

    • @srprantor
      @srprantor 3 หลายเดือนก่อน

      us

  • @vinodiitbhu
    @vinodiitbhu 11 หลายเดือนก่อน +1

    Thanks bhaiya quality content ke liye

  • @manmeetpatel606
    @manmeetpatel606 2 ปีที่แล้ว +7

    For the book allocation problem, the question mentions that each student should get atleast 1 book.
    With the solution shown, if we have an the pages array = [30, 40, 40, 30] , number of students = 3.
    Then, the isPossible function will return True for a mid value of 70, even though the 3rd student will not get any books.
    i.e Student 1 - 30 + 40 pages
    Student 2 - 40 + 30 pages
    Student 3 gets no books. Therefore, this should not be possible solution with mid = 70.
    We need to add a check at the end of isPossible function => if (studentCount == m) return true;

  • @bhaveshs1745
    @bhaveshs1745 2 ปีที่แล้ว +2

    Bhaiya is lecture mein bahut mazaa aya! 🔥 Questions ke level kaafi tough they but mazaa aya sikh ke. Thank you for this series!!

  • @Captain_Pikachu
    @Captain_Pikachu 2 ปีที่แล้ว +3

    // WOOD CHOP QUESTION
    #include
    using namespace std;
    bool canGetWood(int arr[],int n,int mid,int req_wood){
    int wood=0;
    int val=0;
    for(int i=0;i

  • @AnotherGmail-z7n
    @AnotherGmail-z7n ปีที่แล้ว +1

    Adding a correction in this code :
    first of all we will check if n > m i.e (no of books should be greater than no of students) if it is not then we will return -1 bcoz we have more students and less books so we can't allocate book to each student.
    add this if condition in starting of the while loop
    if(m>n){
    return -1;
    }

  • @danishbirsujlana4826
    @danishbirsujlana4826 2 ปีที่แล้ว +3

    1:01:22 why we updated lastPos to stalls[i]?

    • @CodeHelp
      @CodeHelp  2 ปีที่แล้ว +2

      It means last cow is placed at that position.
      That’s why

    • @danishbirsujlana4826
      @danishbirsujlana4826 2 ปีที่แล้ว

      @@CodeHelp yes sir, understood 👍👍

  • @prasad616
    @prasad616 6 หลายเดือนก่อน

    hiii everyone ,
    we need to add on more condition in this code i.e,
    if(m > n){
    return ans;
    }
    because some cases have students more than books, So in that case we need to return ans (-1).
    thank you

  • @pratyush2331raj
    @pratyush2331raj 2 ปีที่แล้ว +5

    Solution for Eko SPOJ
    #include
    #include
    #define int long long int
    using namespace std;
    bool isPossible(vector arr, int n, int m, int mid) {
    int sub = 0;

    for(int i = 0; i < n; i++) {
    if(arr[i] > mid) {
    sub += (arr[i] - mid);
    }
    }
    if(sub >= m) return true;
    else return false;
    }
    int allocateWoods(vector arr, int n, int m) {
    int s = 0;

    int maxi = -1;
    for(int i = 0; i < n; i++) {
    maxi = max(maxi, arr[i]);;
    }

    int e = maxi;
    int mid = s + (e-s)/2;

    int ans = -1;
    while(s >n>>m;
    for(int i = 0; i < n; i++) {
    int data;
    cin>>data;
    arr.push_back(data);
    }
    cout

    • @sureshmakwana8709
      @sureshmakwana8709 2 ปีที่แล้ว +2

      Thanks man coz of you j could break my 12 hours of headache

  • @RohitRana-tz2lr
    @RohitRana-tz2lr 2 ปีที่แล้ว +2

    I am loving the course bhaiya so much... Earlier I have tried to learn DSA from many other platforms but this type of quality content I never get... Thanks, bhaiya for doing so much for us... This course is full proof diamond :)

  • @webdevsumit8311
    @webdevsumit8311 2 ปีที่แล้ว +5

    In question 1 :
    input:
    4 4
    5 17 100 11
    output:
    100
    If mid = 100
    then
    student 1 = 5+17
    student 2 = 100
    student 3 = 11
    student 4 = NOTHING.....
    and isPossible will return true;
    But we are not getting error because ANSWER is also 100 in which distribution will be like
    student 1 = 5
    student 2 = 17
    student 3 = 100
    student 4 = 11
    Sorry bhaiya but I found that....

  • @nikhilupadhyay4191
    @nikhilupadhyay4191 2 ปีที่แล้ว +1

    abhi dekh rha hu video bhaiya poora maza aa rha h thnk u from bottom of the heart❣❣❣

  • @chhatrapathisivajilakkimse8108
    @chhatrapathisivajilakkimse8108 2 ปีที่แล้ว +3

    I got stuck at this point. While checking the possibility , why we always have to place the cow at first position ? There might be a case where C1 at 0 fails but placing it somewhere else would make possible solution . Can anyone explain ?

    • @yashpatil4344
      @yashpatil4344 2 ปีที่แล้ว +1

      because we are sorting the array... so anyhow C1 has to be placed at the zeroth index to get any chance to have a maximum distance.

  • @akshatjain9789
    @akshatjain9789 ปีที่แล้ว +1

    in book allocate problem you need to add this
    if(numofbooks

  • @saurbhmoynak3905
    @saurbhmoynak3905 2 ปีที่แล้ว +3

    Consistency is more important than perfection : )......Love the videos !

    • @udaypratapsingh8923
      @udaypratapsingh8923 2 ปีที่แล้ว +1

      kitne consistent ho bhai tu .... khai chalra hai abhi ..

  • @ASMR-bu8qc
    @ASMR-bu8qc 2 ปีที่แล้ว

    Sir mujhe iss video me lagbhag 5-6 hours lag gaye samajhne me. But abhi confidence agya khud se solutions karne k baad. Thanks :)

  • @pratham654
    @pratham654 2 ปีที่แล้ว +3

    At 58:50 Why do we write e = mid-1, as we have to find the largest minimum distance so if we are not able to find positions for the cow in the left part of the mid then we should go for the right part with the statement ( l = mid +1 ) in the else part.
    Please explain?

    • @viteshkhurana5177
      @viteshkhurana5177 2 ปีที่แล้ว +1

      If we are not able to find the possible solution for a mid value that means there will be no solutions for any value greater that mid value that why we used e=mid-1, so that we can decrease the value of mid and try to find a possible solution with that value.

    • @pratham654
      @pratham654 2 ปีที่แล้ว

      @@viteshkhurana5177 we are solving aggressive cows and if the cows can fight when they were mid distance apart...that means any value lower than mid can be neglected

    • @pratham654
      @pratham654 2 ปีที่แล้ว

      @@viteshkhurana5177 ok ok now I got it...btw thank you bro...

    • @priyabratroutray8184
      @priyabratroutray8184 2 ปีที่แล้ว

      @@pratham654 how you got Plz explain bro

    • @pratham654
      @pratham654 2 ปีที่แล้ว +1

      @@priyabratroutray8184 So let's take an example, suppose we have 10 stalls and we have 5 cows. So We know that the max dist. should be 2. But now In the first pass when we have mid=5, then we know that we are not able to place each cow 5 distances apart so for that reason we entered in the condition e = mid - 1. And for example. our 'mid' value goes to 1 then we are able to place the cows so after that we save 1 as the temporary correct answer and then we see the right side of the mid i.e., Is there any max size available than our temporary answer at which we could place all the cows.
      I hope It would clear your doubt :)

  • @sahilmehta9330
    @sahilmehta9330 ปีที่แล้ว +2

    if(m>n) condition required in book allocation problem solution*

  • @Gaurav-im1df
    @Gaurav-im1df 2 ปีที่แล้ว +4

    #include
    using namespace std;
    bool isPossible(int arry[] , int size ,int mid, int value){
    int sum = 0;
    for(int i=0; i= value){
    return true;
    }
    }
    return false;
    }
    int maxInt(int arry[] , int size , int value){
    int maxi = -1;
    int start = 0;
    for(int i=0; i

  • @MotivationShorts497
    @MotivationShorts497 ปีที่แล้ว +1

    Aaj ke lecture mai confidence apne minimum value pe pahuch gya hai 🙂🙂🥲