Minimum Limit of Balls in a Bag | Detailed | Why Binary Search | Leetcode 1760 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 35th Video of our Playlist "Binary Search : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a good Binary Search problem : Minimum Limit of Balls in a Bag | Wrong Approach | Why Binary Search | Leetcode 1760 | codestorywithMIK
This is a very famous topic - "Binary Search On Answer" because the statement clearly mentions "Minimize the Maximum Penalty".
Whenever you see statements in which we have to either "Minimize the Maximum Value" or "Maximize the Minimum value", go for Binary Search On Answer.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Minimum Limit of Balls in a Bag | Wrong Approach | Why Binary Search | Leetcode 1760 | codestorywithMIK
Company Tags : Amazon OA
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Arrays/Binary Search/Minimum Limit of Balls in a Bag.cpp
Leetcode Link : https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
The problem is solved using binary search on the possible values of the maximum ball size (mid). The goal is to minimize the largest size of any ball after performing at most maxOperations splits.
Define the Search Range:
The smallest possible ball size is 1, and the largest is the maximum value in the nums array (max(nums)).
Binary Search:
For each midpoint (mid) in the range, check if it's possible to make all ball sizes ≤ mid using at most maxOperations.
Helper Method (isPossible):
For each ball, calculate the number of operations needed to reduce its size to ≤ mid.
If the total operations exceed maxOperations, mid is not feasible.
Update Search Range:
If mid is feasible, try smaller values (r = mid - 1) to minimize the result.
Otherwise, increase mid (l = mid + 1) to find a feasible solution.
Result:
The smallest feasible mid is the answer.
✨ Timelines✨
00:00 - Introduction
#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik