BS-14. Find the Smallest Divisor Given a Threshold | Binary Search
Vložit
- čas přidán 26. 07. 2024
- Problem Link: bit.ly/3Cl6KB6
Notes/C++/Java/Python codes: takeuforward.org/arrays/find-...
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
This problem is literally the same as koko eating bananas problem, yet you took the time to explain it separately. Kudos for the hardwork
solved by myself, thanks a ton!!!!!!!!!!!!!!!!!!!!!!!!
solved in just one go without a single error with intuition from previous videos. Love you striver for such amazing content..
just watched the prev question vid and solved this question by myself only thanks striver absolutely the best DSA course
😁same here
Same
yeah!!
Here's an easy way to find the ceil while doing division: return (x+y-1)/y;
If we want to avoid overflow with x+y then simply doing 1+(x-1)/y will work too
Can you explain this please?
Literally found the same thing in codeforces blog article
int maxx(vector nums){
int n = nums.size();
int ans = 0;
for(int i=0; i
1 min 50 seconds into the video and I know how to solve this question. lol. What a guy!! people like you are true 💎. hats off.
Striver Explanation is so smooth and easy to understand ..❣
Your explanation is really good, I actually regret wasting 3.5 months: March , April, May and June. Babbar has explained binary search in a very poor manner. I couldn't solve most questions. My friends told me to learn it from this channel but looking at the playlist length , I avoided it . Totally my fault, and here I am able to atleast think and come up with a solution. Now I understand why people say learn from Striver.
i coded it by myself...understanding the previous videos .......thank you bhai.........my thinking capacity is increasing
SAME BRO
I saw comments before watching the video, people were able to solve so I got jealous and solved it on my own 😂 thank u striver
I solved this problem without seeing the video. Thank you for teaching me so well!
Understood :), Thank so much , i always faced difficulty in when i should take high=mid-1 or high=mid . You teach all the ques with the same pattern. This helped me a lot
hey I want to know how to figure out when to decide high= mid-1 or mid. In which video he explained this concept.
@@akuma_168
You always do mid-1 because you are dividing your given data into two data set leaving the middle element. Cause you have already checked for the middle element. And after checking the middle element, you make a decision that you have to go left or you have to go right.
I hope this made you clear. I may be wrong and correct me if I am. I am a newbie too.
too good bro... after smashing dp playlist im here and with each video my confidence level on BS Q increasing rapidly🔥🔥
Absolute amazing DSA course thank you able to solve this myself
Understood! Wonderful explanation as always, thank you very much for your effort!!
i literraly solved by myself it is same as koko eating bananas ,tank you striver bhaiya for this amazing content,i am paying my internet bills to watch this types of content only
Thanks Bro, Now I am getting Binary Search and able to do by myself ;) Understood;
This is literally same as Koko eating banana well explained brother
wow! did this one on my own as well! Thanks to you!
Completed this today, thanks again
understood
Thank you striver for such an amazing explanation
Understood,Thanks Stirver for this amazing video.
Thanks a ton for all the help. Great work. Noble deeds.
Understood :)
Coded whole code on my own,thanks!!
Thanks for the explanation !! I was able to solve the question on my own🙂
Thank you Striver understood everything
Understood Striver! You are amazing!
Understood Very Well!
Thanks a lot Striver Bhaiya
understood thoroughly
Understood✅🔥🔥
Thank you.
Very much similar to the question of Koko eating bananas.(Just my opinion)
exactly
Understood !! 😎😎
understood 😇
understood💝
its just like a previous one , i did it bro
Understood ❤
understood brother
understood!
understood. solved by myself
ty sir
Understood..!!
Understood :)
coded it all by myslef!!! thank you soo much for such an amazing playlist!!! following each and every video of yours!!
no big deal !!
its similar to koko eating bananas.. me n my friends all were able to solve it... Ha Ha Ha !!
yeah its the same as koko eating bananas just the language is different😁
Thank you Striver, you are the best of DSA CZcamsr
understood😍
tq striver
Understood
Please update the CP sheet, to a checklist kind of a sheet, just like you have done with the DSA sheets!
understood
understood :)
Another Hard Problem is made easy here.
solved it by myself
same as Koko Eating Bananas
Sliding window par small series bhi karwado
Done
we can also start low from array min
If there are 0s in the array then the
Return -1 if n>limit condition will fail
Understood:)
Thank you striver for such a great content ❣❣
done
int maxx(vector nums){
int n = nums.size();
int ans = 0;
for(int i=0; i
12:10 Reverse Polarity
hello striver maybe we can do the binary search from min(arr) to max(arr) that will have less range of binary search and it is also working correctly
can someone please reply
The loop that finds the maximum value in the array (maxi) has a time complexity of O(n), where n is the length of the array.
The binary search is performed on the range from 1 to maxi. The binary search algorithm has a time complexity of O(log(maxi)), where maxi is the range of possible divisors.
Inside the binary search loop, the sumByD function is called, which has a time complexity of O(n). This is because it iterates through the entire array.
Therefore, the overall time complexity is O(n) (for finding maxi) + O(log(maxi)) (for binary search) + O(n) (for sumByD) = O(n + log(maxi) + n).
Sir, so what's the time complexity of this code?
Thank You!!
First view ❤
Bro,how much time is needed to practice DSA?
"understood"
can we take low=min_element in array rather than we take low=1??
no bcoz...we choose lo and high based upon the values where the dummy_threshold can reach max and min...so if u find the dummy_threshold value by using 1 it will be the maximum u can get but if u find the dummy_threshold using lo then its greater then that of 1 . Along with that hamare question my ek possiblity ye bhi ho sakti hai ki threshold value kaagfi jada di ho toh us case me tum agar max threshold nikali hai toh 1 se hi nikalegi .
Habibi ye toh lappu sa question hai .....khud hi ban jave .....shukriya
Last 2 videos.. Really related to this question.....
Advice = plz watche last 2 videos
🙌🙌🙌🙌
I didn't understand why he took the ceil ?
able to solve myself after 3:52
US💯
what is int div?
Consistency ❤❤
Bhaiyaa I have just passed class 12 and my result of jee is not good enough to get any nits,gftis........so, please answer to my query that what would be better choice for me either joining newton school of technology or scaler school of technology Brand new bs ms programme OR, should taking a drop for cse at NIts,IIITS,Gftis........????....
please give your suggestion🙏🙏🙏🙏🙏 please answer my queries ASAP
both the above school you mentioned are bullsh@t , pls don't" join either . Go for Thapar or take drop and join IIT,NITS,IIITs .
Hello bhaiya ! i have been following your dsa since a long time ...now-a-days there are a lot of courses that are floating on yt (paid approx 5k or 6k ) each and every youtubers i now from faraz , nishant , anuj apna college everyone is selling their courses that are starting fron july ownwards ...but i know no can beat your level of dsa problem solving ....are u gonna launch any dsa course too ?? ...i trust only u when it comes to dsa ...and dont want to waste money on this courses unless it is yours ... please reply bhaiya are u launching any dsa course ....??
no
dont even think of buying their courses. follow him and you are good to go. just gotta have sume discipline and consistency
youtube pe sub hai or kya chahiye 300 400 problem deklo na hr topic me se
my n>limit but where is n declared timing 15:28 sec
same as koko
*************JAVASCRIPT CODE*************
function smallestDivisor(arr, threshold) {
let left = 1,
right = (ans = Math.max(...arr));
while (left Math.ceil(el / mid))
.reduce((acc, curr) => curr + acc, 0);
if (sum
math version of koko problem
bhai kab khatm hogi ye series
###Use float datatype to use ceil function###3
bool poss(int mid,vectorarr,int limit){
for(int i=0;i
bro if possible try to solve 2-3 problems in one video like you did for array
Reduces the search index
@@takeUforward okay, I was asking so that you can complete all the remaining ones as early as possible, string linkedlist ,bit manipulations, stack ,queue so many things left and placement season coming so we can cover all the lectures, Ik you have other works but the way you explain concepts I want to study everything from you , if possible please try to cover up all as early as possible .
@@ambaradhikari7425 same but individual videos are better for people having less attention span(like me)😅
@@pratikshadhole6694 yeah same but videos 3-4 ho ya phir 1-2 , agar problems solve ho raha hai toh koi dhikkat nehi? Btw have you just started doing dsa?
Bro plz complete this series before july 1
I will try for sure
@@takeUforward ❤️
bhai ...ap odia ho kya ? i mean ... are you from odisha ?
First comment
woooooo 1st comment
😒😒
us
if you watch koko bananas question this question is a real banana
Understood
understood
understood:)
Understood
Understood
Understood
Understood
Understood
Understood