Allocate Minimum Number Of Pages
Vložit
- čas přidán 9. 04. 2020
- ALLOCATE MINIMUM NUMBER OF PAGES:
Given number of pages in n different books and m students. The books are arranged in ascending order of number of pages. Every student is assigned to read some consecutive books. The task is to assign books in such a way that the maximum number of pages assigned to a student is minimum.
Example :
Input : pages[] = {12, 34, 67, 90}
m = 2
Output : 113
Explanation:
There are 2 number of students. Books can be distributed
in following fashion :
1) [12] and [34, 67, 90]
Max number of pages is allocated to student
2 with 34 + 67 + 90 = 191 pages
2) [12, 34] and [67, 90]
Max number of pages is allocated to student
2 with 67 + 90 = 157 pages
3) [12, 34, 67] and [90]
Max number of pages is allocated to student
1 with 12 + 34 + 67 = 113 pages
Of the 3 cases, Option 3 has the minimum pages = 113.
PROBLEM STATEMENT LINK:www.geeksforgeeks.org/allocat...
PLAYLIST LINK: • Binary Search | Interv... .
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:
🖊️ : My Pen (Used in videos too): amzn.to/38fKSM1
👨🏻💻 : My Apple Macbook pro: amzn.to/3w8iZh6
💻 : My gaming laptop: amzn.to/3yjcn23
📱 : My Ipad: amzn.to/39yEMGS
✏️ : My Apple Pencil: amzn.to/3kMnKYf
🎧 : My Headphones: amzn.to/3kMOzM7
💺 : My Chair: amzn.to/385weqR
🛋 : My Table: amzn.to/3kMohtd
⏰ : My Clock: amzn.to/3slFUV3
🙋🏻♀️ : My girlfriend: amzn.to/3M6zLDK ¯\_(ツ)_/¯
PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Related Problems For Practice :
Book Allocation Problem (GFG)
Aggressive cow (spoj)
Prata and roti (spoj)
EKO (spoj)
Google kickstart A Q-3 2020
+ Painter Partition Problem
@@TheAdityaVerma + Below Leetcode Problems
1482 Minimum Number of Days to Make m Bouquets
1283 Find the Smallest Divisor Given a Threshold
1231 Divide Chocolate
1011 Capacity To Ship Packages In N Days
875 Koko Eating Bananas
Minimize
774 Max Distance to Gas Station
410 Split Array Largest Sum
@@shubhamchaudhary8688 Thanks a lot and @ashish choksi for mentioning related problems just because of you guys now I have good command at these types of problems
thanks
@@shubhamchaudhary8688 thanks it helped alot..
I like how he has never mentioned at the start/end of any video to like,subscribe,comment like everyone else does. Just pure meaningful content !!!
i just needed help...what about if student is < k ? why is there no condition for that??
@@divyareddy7622 I tried using
return student == k ;
which will return accordingly
@@divyareddy7622 Actually this condition should return "true" because if students < k that means we have distributed some extra books to a particular student, in that case we can take the extra book from that particular student and give it to a new student until the condition becomes students == k.
This condition is already handled in isValid() function when we return true at the end of function.
For example:- consider the following testcase:
n = 7
array = 15 10 19 10 5 18 7
k = 5
distribution for max = 25: [[15, 10], [19], [10, 5], [18, 7]] : no. of students == 4. But, we can easily take one book from a student and give it to a new student which will give us a no. of students == 5. In this case the function will return true.
Thank You.
Can't believe we're getting such superb quality videos for free.
i just needed help...what about if student is < k ? why is there no condition for that??
Give this guy a grammy for such an awesome explanation of one of the toughest questions :D
I had a similar question asked int the Uber interview and I was blackout, literally impossible to solve this kind of question if you've not solved it before.
Though I solved it using brute force - Recursion but that wasn't the expectation.
This is a unique kind of pattern and I must say I learned a new pattern today. Though I strongly believe that such questions shouldn't be asked as it doesn't check your problem-solving skills.
Awesome explanation, couldn't find anything better on the internet for this problem.
I have a doubt why is there no condition for students
@@hahahaha4217 we divide the array into k parts so students cant be less than k, think of it this way.... you divide 100 in 3 equal halves, now you cant have 2 halves with both less than 33 and also add up to 100 as well.
@@hahahaha4217 Actually this condition should return "true" because if students < k that means we have distributed some extra books to a particular student, in that case we can take the extra book from that particular student and give it to a new student until the condition becomes students == k.
This condition is already handled in isValid() function when we return true at the end of function.
For example:- consider the following testcase:
n = 7
array = 15 10 19 10 5 18 7
k = 5
distribution for max = 25: [[15, 10], [19], [10, 5], [18, 7]] : no. of students == 4. But, we can easily take one book from a student and give it to a new student which will give us a no. of students == 5. In this case the function will return true.
Thank You.
You give Best explanation available on CZcams..It's helping me a lot..
This is the only channel where i understood this problem. Hats off and thanks for all your hardwork and efforts. You are a great teacher 👍
Bhaiya, I have started CP and was struggling in implementation of Binary Search. I watched your full playlist and it really helped me a lot in implementing Binary Search. Thanks.
bestest and simplest explanation of this tough problem on the internet, thank you so much, sir!
love the way you treat the code ! never get such amazing content in free. lots of Love from NITW
Thank you from bottom of my heart. These videos are very helpful.
Eagerly waiting for your upcoming videos.
Really cross through the best teacher all over you tube ....the way you teaches is like making most difficult question as cup of tea for us ....thanks a lot ❤️
If youtube had a love react, every video of yours would get that from me !!!!
Flawless!
As someone who likes teaching, I really look up to you :)
Finally finished this..Eageraly waiting for other playlist..Your every playlist is very helpful..thanks a lot
i just completed this playlist and once again want to thank you brother ! people usually consider binary search topic very easy and leave it, to all those reading this go ahead and watch this playlist from the start you guys wont be disappointed and will definately learn something new .Thank you Aditya bhai !
bro i was totally confused before looking to your video
you just nailed it thumbs up man.
subscriber++;
Thank you brother, you explained it so nicely. Looking forward for your next videos
Lecture 41 mins ka hai lekin feel nahi hua ki bohut lamba hai jab sunn raha tha. Upar se concept barhiya se samaj aa gaya. Thank you aditya bhaiya! ✌
This is the best explanation, I have ever seen. TYSM brother🙌❤
Amazing Explanation!
I had spent 11 days thinking and trying to solve but you explanation was extremely clear.
same goes with me
Thank you for this amazing series. ♥♥♥
Thanks for the wonderful explanations and videos !!
Bro You are Awesome! Raat ke 1 baj rahe hai but apke videos dekhke kabhi bore nahi hua hu. Aur padhne ka mann karta hai. Great series man! Keep up the good work.
Loved the explanation probably one of the best :)
Even though your Binary Search playlist is sorted in quality of conceptual knowledge,
Yet we can't jump to either half of your playlist 😅😅
This is how legends summarize Binary Search playlist 😂😂
haha good one
Amazing tutorial, Thanks brother!!!
i buy online course but i understand better here...best explanation ever.. thank you
awesome great mind blowing faad pelu zabardast aur kya bolu bhai abhi itna hi aa rha dimag me .. aur aayega to phir likh dunga
As mentioned in the start "this is going to be the best question so far", indeed it was, and the explanation was just as amazing as the question, thanks Aditya.
i just needed help...what about if student is < k ? why is there no condition for that??
Hi Aditya, the explanations are excellent and reflects your great insight and connected understanding. I am sure its helping others like me. Look forward to your Greedy and Backtracking playlist. Cheers.
Bhai, at this moment, I have seen all videos of yours. I can't thank you enough. You are brilliant. 🙏🙏🙏🙏 You are a blessing. 🙏🙏
Please upload videos on RECURSION and BACKTRACKING. Please. 🙏🙏🙏🙏🙏
Finished the playlist and literally I am feeling confident now in BS...Thanks a lot, buddy :).The best thing is ki by solving and watching you how you tackle the problem it created an automatic process ki haan aisa hai to maybe we can apply that..
Thanks a lot.
Best explanation. Keep up the good work.
you explained this in the best way...
keep it up!!!👍👍
Just started with your dp videos it's amazing and best till date... Also request you to please make graph playlists. Eagerly waiting 😊
can i do dp before recursion ? If not please tell about a good recursion series (apart from take u forward). Thanks
@@pranav288 no
@@pranav288 Pepcoding Sumeet sir ke recursion videos. Top quality. And Doing DP without knowing recursion is waste and almost impossible.
i just needed help...what about if student is < k ? why is there no condition for that??
Sir, really really thanks for these awesome videos. I was initially struggling with binary search , but your playlist helped me a lot. Please make videos on graph theory and other imp topics.
And phir se Sir, really really thanks🤘
You are amazing after watching your videos now i am able to do even those questions which i thought yeah nah ho payega. Thank You so much.
Perfect explanation. Far Better than others!!
You're an exceptional teacher.
Done and dusted!! thanks for such an awesome playlist!
✨✨
Sir please backtracking k upar bhi ek playlist upload kr dijiye as it would be very helpful for students whose placement session is approaching
Watched every video of this series and I could say that after your explanation and observation phase of the problem I was able to write whole damm code by myself I am really thankful to you coding was never that much easy until youtube recommendation introduce you to me. Thanks Aditya for make coding easy for us.
Hey, Thank you so much all your knowledge sharing. I am able to perform very nice in all my interviews. Keep up the good work. More power to you.
Keep rocking!!!
bro,can u please guide me/?
puri series dekhi kuch samajh nai aaya y question lekin ek bar m hi samajh aagya ,thanks a lot sir
Sir u are great. The way you teach is amazing. Thank you so much sir for your efforts.
Very Nicely explained. Thank You for this amazing video
Hey sir, Its was just an amazing explanation of the problem and its solution . THANKS U MADE MY LIFE EASIER
Thank-you so much...this application of binary search is very very useful and being used in many areas if we look very closely...I'm shocked even it is used in "Ugly numbers III" and is far better than DP :>
started on 14/7/23,5a.m. and was able to complete this masterpiece series successfully at 15/7/23,3:50 a.m., Grateful for this series.❤💙
Thanks, Aditya. One of the best videos to learn BS.
WOW! Explanation Sir . Keep It Up!!!!
Great explanation! thankyou so much
Bhai you are amazing
Jo concept aapki videos se built hua aisa kahi nhi mila
Thanks a lot but I request you please continue your series of recursion and graph 👍👍♥️♥️
bhaiya completed this series also thanks for ur precious content huge love and support apko,,,..
Please make a playlist on dfs and bfs related questions. Thanks alot for all the help!
thanks a lot for such a great explanation
Such a great explanation bro🔥🔥❤️
Thanks for making video on this Q, and keep making more videos bro🔥🔥
Bhai bhut mast padhte ho tum bhagwan tumhe kamyabi ki nayi uchaio p le jaye
Hi Aditya... Your tutorials are awesome!! ... Could you please share the list of problems if you have handy which are similar to this "Allocate Minimum Number of Pages" problem concept?
I appreciate your hardwork and smart work
The way you are teaching is excellent. I started learning dp from you but from now I am viewing yor all playlist ❤️
Keep uploading other topics content like graph and tree it will help me a lot
Thanks for uploading this kind of contents
Hello Aditya,
You are explaining very well. Please upload the next playlist ASAP and then keep adding the next videos. It would really help.
i just needed help...what about if student is < k ? why is there no condition for that??
@@divyareddy7622 did u get the answer?
Completed this played in 2 days... It took 6-7 hr approx. To complete it. Thank you so much for creating such a great content. 😀
Thanks a lot bhaiya for such a lovely & simple explanation
thank you so much for all the work you put into your videos, made tough topics like DP seem so simple.please upload more videos on important topics and questions from placement point of view, and maybe some tips and tricks also. You're like that friend who teaches imp topics 30 mins before the exam and all that only comes in the paper🔥🔥🔥 eagerly waiting for all the upcoming vids, i have notifications on!!
Thanks a lot for all that appreciation ✌️😅
@@TheAdityaVerma Men will be Men hahaha
@@SandeepKumar-qw3tv phirbhi sbse lamba creative comment yehi hain haha
@@SandeepKumar-qw3tv I saw that, he only replayed to women...😅😅😅😅😅😅
thanks aditya bhaiya to make understandable that problem ,
i was not understanding on other channels
amazing explanation, thank you so much
Awesome. Thanks for your effort :)
Thnx a lot bhia..... please keep making more such videos....
completed this series in two days, really amazing ❤❤
same here... completed today in two days!!!!
Thank you very much.
Bro please keep making videos they are really very helpful
And thanks to you I am finally able to prepare my binary search properly
.thank you for making this videos.
Thx for great playlist
"To me to fan hu, tum bhi ban jao.. Thankyou" Best line bhaiya, we are already your fan.
Thank you Sir, Very helpful tutorial, Love from Bangladesh.
"Tu khel jaake maje kar" 🤣🤣🤣🤣🤣🤣
I liked the video in the first half, after watching code, I wanted to like it again.😂😂
Thanks for this!
Thanks for wonderful explanation
quality content brother thanks
very goooood,,,vaaaaaaaaaaaaaaahhh bro.
Thank you so this series
Very well explained. Thanks a lot... 👍👍
Thanks vaia.Completed the whole playlist.Went well♥
made so easy the concept of binary search on answer he is a gem guy
what is most fascinating about his explanation is that you are able to code by yourself before the video arrives at its mid .
i mean who needs the code? when concept is crystal clear .
What a amazing explanation 🤩
Can you share the list of projects that you have implemented? what is the weightage of projects for selection process?
Amazing playlists!
Wow an amazing Explanation.
bhai best !! watched this vid once and solved all the problems in pinned comment in one go .
Bhai bohot sahi explaination
great bhaiya you are superb
best explanation ever found
great explanation , i came here after watching lots of videos on the same topic but nobody explained better than you. Hats of to you bro , ur channel is so underrated but I wish all ur hard work and skills will be much valuable in future.
i just needed help...what about if student is < k ? why is there no condition for that??
@@divyareddy7622 'K' is the number of students. array indexes represent the book numbers and value of arr[i] represent the number of pages in it the array of any particular book.
mja a gya sir 3 video dekhne ke baad finally is video me feel a gyi
14:04 --> as per the given condition, no student can be left idle, so the start index should be bigger than 0 & the end index would be lesser than 100. To assign a student with a book, minimum one book is to be given for sure. Maximum pages he/she will read = max(arr) ...
right because if arr[]={10,60};
in this case mid ==35;
and isValid function returrn true ; //which is not acceptable.
Learning the Best from THE Best
Thanks For this Sir!!
The Best explanation.
thanks buddy really very helpful