Cut Ribbons to Maximize Equal Length
Problem statement
You are given an array ribbons, where ribbons[i] is the positive integer length of one ribbon, and a positive integer k.
You may cut each ribbon into any number of integer-length pieces. Pieces from different ribbons cannot be joined. Return the greatest integer length length for which the ribbons can produce at least k pieces of exactly that length.
Examples
Example 1
ribbons = [9,7,5]k = 3return = 5Lengths 5, 5, and 5 can be cut from the three ribbons. Length 6 yields only two pieces.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.