14. The Painter's Partition Problem-II
β GFG solution to The Painter's Partition Problem-II: find minimum time to paint all boards by distributing work among k painters using binary search on answer technique. π
π§© Problem Description
π Examples
Example 1
Input: arr[] = [5, 10, 30, 20, 15], k = 3
Output: 35
Explanation: The optimal allocation of boards among 3 painters is -
Painter 1 β [5, 10] β time = 15
Painter 2 β [30] β time = 30
Painter 3 β [20, 15] β time = 35
Job will be done when all painters finish i.e. at time = max(15, 30, 35) = 35Example 2
Input: arr[] = [10, 20, 30, 40], k = 2
Output: 60
Explanation: A valid optimal partition is -
Painter 1 β [10, 20, 30] β time = 60
Painter 2 β [40] β time = 40
Job will be complete at time = max(60, 40) = 60Example 3
π Constraints
β
My Approach
Binary Search on Answer + Greedy Allocation
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated