BS-13. Minimum days to make M bouquets | Binary Search
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
Not a easy problem to understand directly by reading it.. Thanks you have made it very simple.
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
Ya I am also facing same problem, I am also not able to understand the problem
@@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???
how much time you takes to reach at that level and what are the hacks u have learnt that helped u ??
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
@@Vivekkumar-zc7mz there are no hacks
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❤
exact same thing but at 2:15
5 mins into the video and I knew exactly how to code it up! Cheers man. This guy has some serious skills!
That's candidate master for ya.
gawd
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 😊.
nunnu touching comment
@@krishnaramtripathi958 thanks bro BTW completed the sheet :).
@@pulkitjain5159Bro Is it possible to connect with you? I have few doubts regarding dsa.
@@pulkitjain5159 bro from where did u learn dsa
Saw the first 9 minutes of the video and able to code it by myself. Such is the clarity in his explanations. Thanks Striver.
Understood everything clearly and was able to code it myself. Thanks a lot Striver :)
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 .
Understood! Amazing explanation as always, thank you very very much for your continuous effort!!
Little by little feeling confident in solving DSA problems. Thank you man!!
Wow !! I am able to understand the intuition behind these problems. Excellent Problem and awesome explanation.
UNDERSTOOD ! Instead, I solved it by my own before watching the video... Thanks to you
I could not wrap my head around this problem until I saw your video, thank you!
Was able to code this on my own, thanks and understood clearly!
Solved this today, 13 Dec 2023. Thank you man for making the problem a cakewalk.
you are a great striver love the way you approach problems ....... Clearly Understood
Thank you Striver bhaiya!
understood. thank you very much for this series.
I wasn't able to solve mid level binary search problems. Now i can easily. I can't thank you enough
Best! Best! Bestest explanation ever!!
Understood completely, tysmm striverrrrrr
understood
Thank you striver for such an amazing explanation...
What a Great Approach Man
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.
Thank you so much Dada, i was able to solve it on my own by taking help from the previous question intuition
Understood, coded it on my own, thanks!!
It becomes easier to understand when Striver starts explaining
Striver always on fire🔥❤ excellently explained 😊
thanks to you was able to do the problem on my own.
wow! very well explained.
Understood Very Well!
Thank you so much for the super clear explanation 🙂
The explanation is so good
thanks for the explanation definitely helped me to understand the problem!
Thanks it wasn't an easy problem statement to understand but after your explanation I was able to solve it on my own. 🙏
Good problem very well explained. Thanks.
could code it by myself before reading the explanation, thanks!
thank you striver understood everything
amazing explantion i was able to do it on my own. 😊
Understand bro great teaching 👍
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!
isPossible() function and taking long long as val = m*k to avoid overflow error is too tricky and helpful to understand the question clearly
Understood :) Thank you so much
you are great sir
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....
Great explanation. TC should include an additional O(n) to find range.
yes correct
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.
Love from Mysore ❤
Best intuition
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?
Understood sir!
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;
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.
how is it an optimization lol? it ulta increases the Tc.
thanks for the video mate
Understood✅🔥🔥
Thank you bhaiya
Keep going thanks alot
Thank you
Understood!
amazing sir
Understood ❤
understood!!!
Understood !! 😎😎
understood!
UNDERSTOOD 🥰
understooood :)
Legendary boss
Understood 👍
understood 😇
Understood🎉
the opposite polarity is very useful.
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
Understood.
happy birthday bhai bhai
UNDERSTOOD
understoood
he is a fire❤🔥❤🔥❤🔥❤🔥❤🔥
ty sir
Understood
nice one
Habibi tussi mast bideo banate ho
Awesome
tq
understood
Better than Paid Courses
Can someone please help me understand what is polarity concept striver was talking about?
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.
can anyone please tell me why here we initialized with ans=high when we're implementing binary search??
It's like mixed form of binary with kadane
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?
shoudlnt we sort in ascending order before doing anyhting?
can we solve this problem by sorting the array an then applying binary search logic ???
Undertsood
🙌🙌👏
Done and Dusted !!!
Can we solve this as multiple peak points
are we not going to add TC of finding max and min of the array??
O((log(max-min))*n) is greater than n. So we ignore the shorter time complexity.
simply binary search is converting o(n2) solution to o(nlogn) solution
"understood"
why +1 in Time Complexity?
understood , crystal clear
why T.C is log( n*(max-min+1)) but not nlog(max-min+1) . IS BOTH SAME???