BS-13. Minimum days to make M bouquets | Binary Search

Sdílet
Vložit
  • čas přidán 21. 06. 2023
  • Problem Link: bit.ly/43ScDRY
    Notes/C++/Java/Python codes: takeuforward.org/arrays/minim...
    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

Komentáře • 195

  • @AyushSharma-sd1ny
    @AyushSharma-sd1ny Před rokem +70

    Not a easy problem to understand directly by reading it.. Thanks you have made it very simple.

  • @adityarajvermaa
    @adityarajvermaa Před 10 měsíci +57

    bro literally I coded it down myself...just came here to understand the problem coz it was too complex to understand. Now i can code medium range problems by myself....sooner or later I will be able to understand the problem as well as we code further

    • @danielhaag756
      @danielhaag756 Před 9 měsíci +4

      Ya I am also facing same problem, I am also not able to understand the problem

    • @samit840
      @samit840 Před 8 měsíci

      @@danielhaag756 tell me one thing bro, i watched the video till 4-5 mins, and then i noticed that we would be doing it same way as we did in KOKO bananas, so is it fine that i watched the video till this???

    • @Vivekkumar-zc7mz
      @Vivekkumar-zc7mz Před 4 měsíci

      how much time you takes to reach at that level and what are the hacks u have learnt that helped u ??

    • @pranavJha93
      @pranavJha93 Před 3 měsíci

      there is one tip i will give u see there two types of cases either you are able to solve a problem either you are not when when you are not able to solve a problem first make notes of it after watching tutorial of it and then do the same question by yourself after 7 days if u are able to do it in by your own without copying that means u actually grabbed the concept of it and it will also boost your confidence @@Vivekkumar-zc7mz

    • @ranjeet_sohanpal
      @ranjeet_sohanpal Před 3 měsíci +2

      @@Vivekkumar-zc7mz there are no hacks

  • @morty6456
    @morty6456 Před 9 měsíci +26

    My strategy of following the striver sheet is that at first I try to solve the question myself and if I am unable to then I come to videos for understanding,
    After reading this question on leetcode, I was clueless even about the question itself 1:35 mins into video and I have solved it on my own.
    Is this magic or something? 😅
    Thank you bhaiyaaaaaaaaaaa❤

  • @udaykulkarni5639
    @udaykulkarni5639 Před 4 měsíci +40

    5 mins into the video and I knew exactly how to code it up! Cheers man. This guy has some serious skills!

  • @pulkitjain5159
    @pulkitjain5159 Před rokem +33

    currently 259 questions kar liye hai apki sheet ke , dekhte hai aur kitne kar pata hu , quality of questions awesome hai bhaiya , monotnic stacks m aur sliding windows m toh kya tagde question daal rakhe hai every question improves thinking in other direction. Ab bas graphs , greedy , trees , heaps aur strings bach raha hai usme bhi umeed hai bahut shandar questions honge. karta hu bhiaya dekhte hai kab tak khatam hogi , jab binary search kar raha tha tab i really wanted ki yeh videos ajaye but jo khud grind kiya na woh alag hi satisfaction tha. kabhi bhulayega nahi yeh questions , jitna video dekh ke bhool jaate hai. ek video ke peeche itni mehnat hoti hai itni research hoti hai , samajh agya. Waise app thoda rest bhi karliya karo aur jyada soya karo , peace of mind jyada important hai. Thank you for free knowledge 😊.

    • @krishnaramtripathi958
      @krishnaramtripathi958 Před rokem +2

      nunnu touching comment

    • @pulkitjain5159
      @pulkitjain5159 Před 11 měsíci +2

      @@krishnaramtripathi958 thanks bro BTW completed the sheet :).

    • @GauravKashyap-ei6mb
      @GauravKashyap-ei6mb Před 11 měsíci

      ​@@pulkitjain5159Bro Is it possible to connect with you? I have few doubts regarding dsa.

    • @vaibhavvm4147
      @vaibhavvm4147 Před 6 měsíci

      @@pulkitjain5159 bro from where did u learn dsa

  • @thegreekgoat98
    @thegreekgoat98 Před 8 měsíci +3

    Saw the first 9 minutes of the video and able to code it by myself. Such is the clarity in his explanations. Thanks Striver.

  • @krishnavamsiyerrapatruni5385

    Understood everything clearly and was able to code it myself. Thanks a lot Striver :)

  • @thisismr900
    @thisismr900 Před 11 měsíci +14

    Thank u striver sir. Really an inspiration to me.
    U know what ,I feel NOW very confident in solving the questions.
    Bas logic samajh aa jaye to code to bas 5 min lagta hai.
    2 days complete , now at 13th video of this playlist .

  • @cinime
    @cinime Před rokem

    Understood! Amazing explanation as always, thank you very very much for your continuous effort!!

  • @raZer.7_
    @raZer.7_ Před 2 měsíci +2

    Little by little feeling confident in solving DSA problems. Thank you man!!

  • @joeljacob4685
    @joeljacob4685 Před 9 měsíci

    Wow !! I am able to understand the intuition behind these problems. Excellent Problem and awesome explanation.

  • @himangshusarma6384
    @himangshusarma6384 Před 11 měsíci

    UNDERSTOOD ! Instead, I solved it by my own before watching the video... Thanks to you

  • @GPT-X938
    @GPT-X938 Před 17 dny

    I could not wrap my head around this problem until I saw your video, thank you!

  • @sauravchandra10
    @sauravchandra10 Před rokem +1

    Was able to code this on my own, thanks and understood clearly!

  • @SumitSingh-dc8pm
    @SumitSingh-dc8pm Před 6 měsíci

    Solved this today, 13 Dec 2023. Thank you man for making the problem a cakewalk.

  • @priyanshunautiyal1662
    @priyanshunautiyal1662 Před 3 měsíci +1

    you are a great striver love the way you approach problems ....... Clearly Understood

  • @faizanahmed9304
    @faizanahmed9304 Před rokem +2

    Thank you Striver bhaiya!

  • @adityaroychowdhury3709
    @adityaroychowdhury3709 Před 11 měsíci

    understood. thank you very much for this series.

  • @Facts-d5f
    @Facts-d5f Před 2 měsíci

    I wasn't able to solve mid level binary search problems. Now i can easily. I can't thank you enough

  • @user-tv6bt4qu7o
    @user-tv6bt4qu7o Před 20 dny

    Best! Best! Bestest explanation ever!!

  • @ishangujarathi10
    @ishangujarathi10 Před rokem

    Understood completely, tysmm striverrrrrr

  • @user-ti3bd8mp1w
    @user-ti3bd8mp1w Před 11 měsíci

    understood
    Thank you striver for such an amazing explanation...

  • @akhileshagarwal5913
    @akhileshagarwal5913 Před 3 měsíci

    What a Great Approach Man

  • @23cash86
    @23cash86 Před rokem +6

    at 3:53 I understood it is binary search, implemented on my own using binary search + sliding window ....Made some modification to sliding window as window cannot be overlapped to count consecutive k elements, got overflow error while checking n< m*k ... typecasted to n< (long) m*k ,finally passed all test cases after 40min.....
    Edit:
    after submiting i watched video and realised its easier to implement possible function , same complexity as sliding window but i could probably code you idea faster and it is simpler XD.
    Grateful for free knowledge from you.

  • @kaushiksen2190
    @kaushiksen2190 Před 7 měsíci

    Thank you so much Dada, i was able to solve it on my own by taking help from the previous question intuition

  • @googleit2490
    @googleit2490 Před rokem

    Understood, coded it on my own, thanks!!

  • @JoyBoy_013
    @JoyBoy_013 Před 4 měsíci +1

    It becomes easier to understand when Striver starts explaining

  • @aksharshah
    @aksharshah Před měsícem +2

    Striver always on fire🔥❤ excellently explained 😊

  • @udatyadeb101
    @udatyadeb101 Před 5 měsíci

    thanks to you was able to do the problem on my own.

  • @abhishekkumargupta117
    @abhishekkumargupta117 Před 7 měsíci +1

    wow! very well explained.

  • @AnmolGupta-oj4lm
    @AnmolGupta-oj4lm Před 11 měsíci

    Understood Very Well!

  • @divya1005
    @divya1005 Před 20 dny

    Thank you so much for the super clear explanation 🙂

  • @Avi-rc5ff
    @Avi-rc5ff Před 21 dnem

    The explanation is so good

  • @stephan24297
    @stephan24297 Před 20 dny

    thanks for the explanation definitely helped me to understand the problem!

  • @danish15
    @danish15 Před 21 dnem

    Thanks it wasn't an easy problem statement to understand but after your explanation I was able to solve it on my own. 🙏

  • @dayashankarlakhotia4943

    Good problem very well explained. Thanks.

  • @MJBZG
    @MJBZG Před 8 dny

    could code it by myself before reading the explanation, thanks!

  • @manavsingh5919
    @manavsingh5919 Před 10 měsíci

    thank you striver understood everything

  • @dipingrover1970
    @dipingrover1970 Před 25 dny

    amazing explantion i was able to do it on my own. 😊

  • @statusupdate7007
    @statusupdate7007 Před 8 hodinami

    Understand bro great teaching 👍

  • @divyanshubaranwal3791
    @divyanshubaranwal3791 Před 21 dnem

    I forgot to write noOfB += (cnt / k); again outside the loop in possible function, and it took me so much time to solve it myself, but i was able to do it after some time. So much thanks!

  • @Manishgupta200
    @Manishgupta200 Před 11 měsíci +1

    isPossible() function and taking long long as val = m*k to avoid overflow error is too tricky and helpful to understand the question clearly

  • @sakshinaruka3440
    @sakshinaruka3440 Před rokem

    Understood :) Thank you so much

  • @vedantrajanikantlatthe735

    you are great sir

  • @ArijitsClasses
    @ArijitsClasses Před 6 měsíci +2

    Good evening sir, this is Arijit from Kolkata. Your videos are super amazing and helpful, getting confidence in attempting leetcode problems...could even solve few of them.
    Sir the purpose of this comment is, as you said in one of the TEDX videos that in your college days you used to earn through blogging...may you please suggest me some tips, how can I earn through blogging, and recommend some blogging websites from where I can earn too....

  • @alessandrocamilleri1239
    @alessandrocamilleri1239 Před rokem +1

    Great explanation. TC should include an additional O(n) to find range.

  • @shamanthhegde2820
    @shamanthhegde2820 Před 4 měsíci +1

    while solving the same problem in leetcode, i encountered a condition where the code might fail. for instance when there are enough flowers but they are not adjacent to make enough bouquets.
    so during that case our low pointer will go beyond the size of the array. In order to counter that , we have to check the position of low...if the position of low > maxDay then we have to return -1 as we were not able to satisfy number of bouquets.

  • @animalbyte453
    @animalbyte453 Před rokem

    Love from Mysore ❤

  • @prakhargarg4166
    @prakhargarg4166 Před 21 dnem

    Best intuition

  • @pushankarmakar1783
    @pushankarmakar1783 Před 4 měsíci +2

    why cant we do it in a way where the possible() function would return the bouquets we are able to form and then we deal with what to do in the binary search?

  • @smoothgaming7822
    @smoothgaming7822 Před 8 měsíci

    Understood sir!

  • @akshaygupta811
    @akshaygupta811 Před rokem

    A small optimization: defining long longs and checking for the condition m*k>n is not necessary,
    once the binary search finishes, if m*k>n is true, then our Low pointer would point at n.
    Hence at last we can just simple write:
    if (low==n) return -1;
    else return low;

    • @6mahine_mein_google
      @6mahine_mein_google Před 10 měsíci +1

      It really isn't an optimization per se. Because if we calculate it beforehand we dont need to apply binary search at all , if(m*k>n) is true then it will straight away throw -1 whereas in your approach it would still take O(N*logN) , because it will go into binary search loop nevertheless.

    • @dank7044
      @dank7044 Před 8 měsíci

      how is it an optimization lol? it ulta increases the Tc.

  • @GuruPrasadShukla
    @GuruPrasadShukla Před rokem

    thanks for the video mate

  • @YourCodeVerse
    @YourCodeVerse Před 6 měsíci

    Understood✅🔥🔥

  • @user-tk2vg5jt3l
    @user-tk2vg5jt3l Před 5 měsíci

    Thank you bhaiya

  • @kaushiksen2190
    @kaushiksen2190 Před 7 měsíci

    Keep going thanks alot

  • @srikanthkumar6842
    @srikanthkumar6842 Před 9 měsíci

    Thank you

  • @Anony.musk01
    @Anony.musk01 Před rokem +1

    Understood!

  • @bharatmundra9568
    @bharatmundra9568 Před 11 měsíci

    amazing sir

  • @senseiAree
    @senseiAree Před 8 měsíci

    Understood ❤

  • @nuraynasirzade
    @nuraynasirzade Před 2 měsíci

    understood!!!

  • @user-is6ky7pp2n
    @user-is6ky7pp2n Před měsícem

    Understood !! 😎😎

  • @humanity7880
    @humanity7880 Před 11 měsíci

    understood!

  • @AbhishekKumar-nz9dn
    @AbhishekKumar-nz9dn Před 8 měsíci

    UNDERSTOOD 🥰

  • @pihus3498
    @pihus3498 Před rokem

    understooood :)

  • @md.imrankhan6912
    @md.imrankhan6912 Před 10 měsíci

    Legendary boss

  • @aakashpatel1250
    @aakashpatel1250 Před rokem

    Understood 👍

  • @culeforever5408
    @culeforever5408 Před 8 měsíci +1

    understood 😇

  • @divyaagarwal3563
    @divyaagarwal3563 Před rokem

    Understood🎉

  • @cenacr007
    @cenacr007 Před 9 měsíci

    the opposite polarity is very useful.

  • @johndurai2226
    @johndurai2226 Před rokem +4

    Thank you striver bro I am from the south india (Tamilnadu). You are the consistency person keep it up and post videos as well. These are helpfull for us. Please made videos like this consistency.Thank you

  • @chandrachurmukherjeejucse5816
    @chandrachurmukherjeejucse5816 Před 11 měsíci

    Understood.

  • @ritikkurta3363
    @ritikkurta3363 Před 11 měsíci

    happy birthday bhai bhai

  • @per.seus._
    @per.seus._ Před 10 měsíci

    UNDERSTOOD

  • @AnandSharma-ei1fv
    @AnandSharma-ei1fv Před 21 dnem

    understoood

  • @mohammedansil2302
    @mohammedansil2302 Před 21 dnem

    he is a fire❤‍🔥❤‍🔥❤‍🔥❤‍🔥❤‍🔥

  • @KartikeyTT
    @KartikeyTT Před měsícem

    ty sir

  • @dewanandkumar8589
    @dewanandkumar8589 Před 5 měsíci

    Understood

  • @sahilsinghtomar
    @sahilsinghtomar Před 9 měsíci

    nice one

  • @CodeMode9313
    @CodeMode9313 Před 10 měsíci

    Habibi tussi mast bideo banate ho

  • @soumiyamuthuraj3516
    @soumiyamuthuraj3516 Před 10 dny

    Awesome

  • @shaiksoofi3741
    @shaiksoofi3741 Před 2 měsíci

    tq

  • @viratlover6206
    @viratlover6206 Před 9 měsíci

    understood

  • @BiswajitDas-lk7pp
    @BiswajitDas-lk7pp Před 6 měsíci

    Better than Paid Courses

  • @arujain1690
    @arujain1690 Před 10 měsíci +2

    Can someone please help me understand what is polarity concept striver was talking about?

    • @Bharat_Rider
      @Bharat_Rider Před 10 měsíci +2

      Initially low was on the not possible side and high on the possible side. This is polarity. Now as the binary search ends polarity changes i.e. low will be on possible and high on not possible.

  • @garimaarora5311
    @garimaarora5311 Před rokem

    can anyone please tell me why here we initialized with ans=high when we're implementing binary search??

  • @anirbanghosh752
    @anirbanghosh752 Před rokem

    It's like mixed form of binary with kadane

  • @stormragemc4375
    @stormragemc4375 Před 16 dny

    if i may once you've found out 12 (mid) is possible, why do you still need to eliminate the ranges and continue looking when it's safe to assume that since you've ordered the list the first number you found possible would be the smallest possible and u got ur answer already?

  • @tabrezahmed1000
    @tabrezahmed1000 Před 9 měsíci

    shoudlnt we sort in ascending order before doing anyhting?

  • @abhinavanand1904
    @abhinavanand1904 Před 10 měsíci

    can we solve this problem by sorting the array an then applying binary search logic ???

  • @codeman3828
    @codeman3828 Před 5 měsíci

    Undertsood

  • @ganeshmula4508
    @ganeshmula4508 Před 9 měsíci

    🙌🙌👏

  • @AK-nj1je
    @AK-nj1je Před 3 měsíci +1

    Done and Dusted !!!

  • @AMITDANSENA-qe9px
    @AMITDANSENA-qe9px Před měsícem

    Can we solve this as multiple peak points

  • @samreenimam8608
    @samreenimam8608 Před 6 měsíci +1

    are we not going to add TC of finding max and min of the array??

    • @vishious14
      @vishious14 Před 5 měsíci

      O((log(max-min))*n) is greater than n. So we ignore the shorter time complexity.

  • @darkpheonix6592
    @darkpheonix6592 Před 10 dny

    simply binary search is converting o(n2) solution to o(nlogn) solution

  • @raghavkansal3765
    @raghavkansal3765 Před 11 měsíci

    "understood"

  • @Shreya-hg7vo
    @Shreya-hg7vo Před měsícem

    why +1 in Time Complexity?

  • @devchangela8379
    @devchangela8379 Před rokem

    understood , crystal clear

  • @AkOp-bf9vm
    @AkOp-bf9vm Před 5 měsíci

    why T.C is log( n*(max-min+1)) but not nlog(max-min+1) . IS BOTH SAME???