PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's proficiency in algorithm design, particularly applying binary search over a monotonic answer space and managing integer versus floating-point precision when maximizing piece length.

  • Medium
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Find maximum cable length by cutting

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given N cables with integer lengths and a target K. Cut the cables into pieces of equal integer length L to produce at least K pieces; maximize L. If impossible, return 0. Describe an algorithm using binary search on the answer and analyze its complexity. Follow up: support non-integer lengths with precision 1e-3.

Quick Answer: This question evaluates a candidate's proficiency in algorithm design, particularly applying binary search over a monotonic answer space and managing integer versus floating-point precision when maximizing piece length.

Given cable lengths and target piece count k, return the maximum integer piece length that can produce at least k pieces.

Constraints

  • Inputs are provided as Python literals matching the function signature.
  • Return a deterministic exact-match result.

Examples

Input: ([802, 743, 457, 539], 11)

Expected Output: 200

Explanation: Classic cable cutting.

Input: ([5, 5], 20)

Expected Output: 0

Explanation: Impossible target.

Input: ([], 1)

Expected Output: 0

Explanation: No cables.

Hints

  1. Choose a representation that makes the core operation simple.
  2. Handle empty and boundary inputs before the main algorithm.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Minimize Travel Assignment Cost - Bloomberg (medium)
  • Determine Balloon Popping Time - Bloomberg (medium)
  • Solve meeting and tree problems - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)