Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82837bb

Browse files
refactor 1049
1 parent80f94ad commit82837bb

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
packagecom.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
publicclass_1049 {
284
publicstaticclassSolution1 {
295
publicintlastStoneWeightII(int[]stones) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp