The Cutting Ribbons interview question is an optimization problem. You are given an array of ribbon lengths and an integer k. You can cut the ribbons into any number of smaller pieces, but you want to find the maximum integer length L such that you can obtain at least k pieces of length L. This Cutting Ribbons coding problem is a classic "binary search on the answer" task.
Google and Meta ask this to see if a candidate can recognize a monotonic property. If you can cut k ribbons of length 10, you can certainly cut k ribbons of length 5. This realization allows you to avoid trying every possible length and instead use a much faster search strategy.
This utilizes the Array, Binary Search interview pattern.
Ribbons: [9, 7, 5], k = 3.
Whenever you are asked to find the "maximum minimum" or "minimum maximum" of something, or the "largest possible X that satisfies a condition," immediately check if Binary Search on the Answer is applicable. It’s a very high-signal pattern for interviewers.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Adjacent Increasing Subarrays Detection II | Medium | Solve | |
| Missing Element in Sorted Array | Medium | Solve | |
| H-Index II | Medium | Solve | |
| Minimum Time to Complete Trips | Medium | Solve | |
| Minimum Time to Repair Cars | Medium | Solve |