BS-18. Allocate Books or Book Allocation | Hard Binary Search

preview_player
Показать описание

Notes/C++/Java/Python codes:

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.

You can follow me across social media, all my handles are below:

0:00 Introduction of Course
Рекомендации по теме
Комментарии
Автор

Hi Raj, Hriday here...I have been following your SDE sheet for a while, and I'm ecstatic to share that I've been offered an SDE intern position at Arcesium in my second year of Engineering, All thanks to youuuu !!!!

manrar
Автор

understood!!.... at 22:30 low = 64 as low = mid+1 => low = 63+1 = 64 : )

gunduboinadileep
Автор

I firstly watched the whole explanation till linear search then I was able to write the whole code by myself in binary search. Thank you striver

Codro
Автор

17:30 There is a mistake in condition as (cntStud == m) will be true in this testcase but let pages[] = {25, 46, 28, 43, 50}. In this upto 70 pages, 5 students will be returned from second function but the moment 71 is checked no of student required will reduce to 3 as (25+46), (28+43), (50). And condition cntStud == m will reject it. Note that 71 is the maximum pages a student is allowed to take, so i can distribute (25+46), (28), (43), (50) to 4 students.
Thus condition should be (cntStud <= m).

itgofcp
Автор

Watching the whole playlist is just like watching anime and waiting for upcoming episodes tooo 😝

Veer_Shiv
Автор

The way you got us to think why Binary Search -> was great !!! ...and this is actually what is to be taught in problem solving sessions. thank You very much Striver

secretvibz
Автор

Once you explained the logic I wrote the code all by myself for both brute and optimal it's because of your lecture my cognitive skill is increasing thanks a lot❤❤❤
I

VineetKumar-fkrl
Автор

No words to express my gratitude towards the man teaching here 😇

abhigna_y
Автор

Respect++ for Raj bhaiya!!
If i was not learning dsa in such a constructive way idk where would i have been!!
I solved this question by my own all thanks to you for creating this playlist and i am following your AtoZ sheet its amazing!!!
Thanks 🌟🌟🌟🌟✨✨

lakshayyadav
Автор

This is not an tough question if you are following this playlist this is an cakewalk
Solve by own
Tysm Understood everything❤

ujjawalraj
Автор

I have a slight correction in the brute force solution. The countStudent returned from the helper function can be less than or equal to number of students(m) given. (cntstu<=m) But Why?

If we take an example with minor changes like this - arr= (2, 3, 1, 1, 1) and m=5, the possible answer is 3 right.
For 3 as limit to each student:
Student 1 - 2
Student 2 - 3
Student 3 - 3
Student 4 - 0
Student 5 - 0
So the algorithm says that there is no solution to this.

Think generally, the pages limit for every student is not mandatory right but it should be the highest in all thats it. So the student 3 in the above problem can just be alloted 1 page book and 1 page book to student 4 and 1 page book to student 5. Its a solution to it right.

So if we just check for cntstu<=m, we can also do solve cases like this.

harshith
Автор

thanks bhaiya i have completed more than 80 questions in the last 3 weeks and it's really helping me in web dev also

oyeesharme
Автор

Thank you very much sir. I've Been stuck on this problem from the last 3-4 days, watched a lot of videos but your explanation is just on some different level.

VishalKumar-bjnl
Автор

It is hard, one of the question i didn;t get even after reading it like 5 times. Nice explaination as always!

arujain
Автор

Can wait to get this playlist completed. Thanks for the free content.

HarshKumar-ipnr
Автор

You saved my day, Striver bro. I was struggling without the Dry Run of the problem. This video solution is very helpful to understand everything like the approaches using Linear search, Binary Search, the Time Complexity, Dry Run, Intuition and Psuedo code. Thank you so much, bro.

aswinbarath
Автор

This problem is quite similar to "allocate minimum number of pages" and "painters partition" problems

shankargowd
Автор

Please don't change problem links of A-Z dsa sheet frequently recently all gfg link got replaced with code studio links. It breaks the flow for those who are already preparing from the sheet. Instead of replacing existing links with new link you can add new section for code studio links @takeUforward

vedfutane
Автор

after watching the whole playlist this question was easy for me

abdussalam-
Автор

This video is more understanding then code help's allocate books. Thanks

anish-acharya