Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 7d6cd79

Browse files
committed
945 finish
1 parent e3636c5 commit 7d6cd79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ func minIncrementForUnique(A []int) int {
1414
res := 0
1515

1616
for n := 0; n < max; n++ {
17-
if counts[n] <= 1 {
17+
if counts[n] <= 1 { // no redundance
1818
continue
1919
}
2020
redundance := counts[n] - 1
21+
// move all redundance to n+1
2122
res += redundance
2223
counts[n+1] += redundance
2324
}

0 commit comments

Comments
 (0)