Smash The Bricks(NG)

Problem Overview

  • Determine the minimum total blows to smash all bricks using two hammers: big (smashes any brick, limited uses) and small (reduces required newtons by 1 per hit).
  • Input: int bigHits; int newtons[n] with distinct values.
  • Output: long[][] = [[total hits], [sorted 1-based indices for big], [sorted 1-based indices for small]]; use [-1] if a hammer isn't used.
  • Constraints: 1≤n≤2e5, 0≤bigHits≤2e5, 1≤newtons[i]≤1e9.
  • Real-world context: force in newtons; asked in Wayfair interviews; a common coding interview problem and interview question.

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: