Last Stone Weight
You have stones with given weights. Each turn, take the two heaviest stones with weights x <= y and smash them: if x == y both are destroyed, otherwise the stone of weight y - x remains. Print the weight of the last remaining stone, or 0 if none.
Constraints
1 <= n <= 30 1 <= weight <= 1000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.