Skip to content

Commit 82837bb

Browse files
refactor 1049
1 parent 80f94ad commit 82837bb

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

src/main/java/com/fishercoder/solutions/_1049.java

-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 1049. Last Stone Weight II
5-
*
6-
* We have a collection of rocks, each rock has a positive integer weight.
7-
* Each turn, we choose any two rocks and smash them together.
8-
* Suppose the stones have weights x and y with x <= y. The result of this smash is:
9-
* If x == y, both stones are totally destroyed;
10-
* If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x.
11-
* At the end, there is at most 1 stone left. Return the smallest possible weight of this stone (the weight is 0 if there are no stones left.)
12-
*
13-
* Example 1:
14-
* Input: [2,7,4,1,8,1]
15-
* Output: 1
16-
*
17-
* Explanation:
18-
* We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
19-
* we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
20-
* we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
21-
* we can combine 1 and 1 to get 0 so the array converts to [1] then that's the optimal value.
22-
*
23-
* Note:
24-
* 1 <= stones.length <= 30
25-
* 1 <= stones[i] <= 100
26-
* */
273
public class _1049 {
284
public static class Solution1 {
295
public int lastStoneWeightII(int[] stones) {

0 commit comments

Comments
 (0)