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

Commit5adecd4

Browse files
refactor 1046
1 parenta1e6274 commit5adecd4

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@
22

33
importjava.util.PriorityQueue;
44

5-
/**
6-
* 1046. Last Stone Weight
7-
*
8-
* We have a collection of rocks, each rock has a positive integer weight.
9-
*
10-
* Each turn, we choose the two heaviest rocks and smash them together.
11-
* Suppose the stones have weights x and y with x <= y. The result of this smash is:
12-
*
13-
* If x == y, both stones are totally destroyed;
14-
* If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x.
15-
* At the end, there is at most 1 stone left. Return the weight of this stone (or 0 if there are no stones left.)
16-
*
17-
* Example 1:
18-
* Input: [2,7,4,1,8,1]
19-
* Output: 1
20-
* Explanation:
21-
* We combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then,
22-
* we combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then,
23-
* we combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
24-
* we combine 1 and 1 to get 0 so the array converts to [1] then that's the value of last stone.
25-
*
26-
* Note:
27-
* 1 <= stones.length <= 30
28-
* 1 <= stones[i] <= 1000
29-
* */
305
publicclass_1046 {
316
publicstaticclassSolution1 {
327
publicintlastStoneWeight(int[]stones) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp