Last Stone Weight
Problem Overview
- Given stone weights, repeatedly smash the two largest; equal weights vanish, otherwise replace with their difference; return the last stone’s weight or 0.
- Input: int weights[n]; Output: integer; Constraints: 1 ≤ n ≤ 1e5, 1 ≤ weights[i] ≤ 10^9.
- Real-world context: a quarry-worker reducing stones by smashing.
- From Factset interviews; a classic 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:
