Intermediatecoding Verified
Given ropes of different lengths that can be cut into pieces, find the maximum piece length L such that you can cut at least K pieces of length L.
ReportedSource: GeeksforGeeks interview experience: Uber SDE-1 off-campus 2021
Quick answerFree
Binary search the length L over [1, max]; feasible if sum(rope // L) >= K; keep the largest feasible L. O(n log max).
Detailed answer· 98 words
Interview PrepUnlock the full answer with Interview Prep
Get a 98-word model answer and a runnable reference solution, plus 28 more Algorithms questions.
Also in Pro (₹499 / 90 days).
Reference solution· runs in the browser sandbox
Interview PrepUnlock with Interview Prep
+ 28 more Algorithms questions in Interview Prep, each with the full answer.