Given an array of integers, increment any duplicate elements until all elements are unique.
Given an array of integers, increment any duplicate elements until all elements are unique. The task is to minimize the sum of the array after making all elements unique.
Example:
// With the input
[7, 2, 1, 2, 4, 3]
// Increment a 2 to get
[7, 2, 1, 3, 4, 3]
// Increment a 3 to get
[7, 2, 1, 3, 4, 4]
// Increment a 4 to get
[7, 2, 1, 3, 4, 5]
// every element is now unique
// => sum : 22
# | Size | % | Users |
---|---|---|---|
#1 | 43 c. | Top 11% | |
#2 | 46 c. | Top 17% | |
#3 | 50 c. | Top 22% | |
#4 | 53 c. | Top 33% | |
#5 | 54 c. | Top 44% | |
#6 | 59 c. | Top 50% | |
#7 | 72 c. | Top 56% | |
#8 | 78 c. | Top 61% | |
#9 | 79 c. | Top 67% | |
#10 | 80 c. | Top 72% | |
#11 | 83 c. | Top 78% | |
#12 | 95 c. | Top 83% | |
#13 | 114 c. | Top 89% | |
#14 | 181 c. | Top 94% | |
#15 | 447 c. | Top 100% |