Solving Last Stone Weight II in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

We have a collection of rocks, each rock has a positive integer weight.

Example 1:

Input: [2,7,4,1,8,1]
Output: 1
Explanation: 
We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
we can combine 1 and 1 to get 0 so the array converts to [1] then that's the optimal value.

Note:

  1. 1 <= stones.length <= 30

  2. 1 <= stones[i] <= 100

  3. 1 <= stones.length <= 30

  4. 1 <= stones[i] <= 1000

See the full details of the problem Last Stone Weight II at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go