Break The Bricks

Problem Overview

  • Break n bricks with two hammers: big (instant break, limited uses) and small (reduces required newtons by 1 per hit); find the minimum total blows to smash all.
  • Inputs: bigHits and newtons[n]; Output: [[total hits], [sorted 1-based indices for big], [sorted 1-based indices for small]], using [-1] if a hammer isn’t used.
  • Constraints: 1≤n≤2e5, 0≤bigHits≤2e5, newtons up to 1e9; indices are 1-based.
  • Context: Resource allocation/optimization in force application.
  • From Morganstanley coding interview; a common interview question problem.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: