Problem · Array

Cut Ribbons to Maximize Equal Length

MediumGoogle logoGoogleFULLTIMEONSITE INTERVIEW
See Google hiring insights

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.

The problem statement continues
Pro

Examples

Example 1

ribbons = [9,7,5]k = 3return = 5

Lengths 5, 5, and 5 can be cut from the three ribbons. Length 6 yields only two pieces.

FastPrep Pro
Reported in 1 Google interview this week

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
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

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
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week