Twitter Online Assessment (OA) - Unique Twitter User ID Set
Given an array of integers l
with size n
, write a function that determines the minimum
sum of another array l_unique
with size n
such that:
l[i] <= l_unique[i]
for all0 <= i < n
;l_unique[i] != l_unique[j]
for all0 <= i != j < n
.
Example 1:
Input: l = [3, 2, 1, 2, 7]
Output: 17
Explanation: In this case, one l_unique
could be [3, 2, 1, 4, 7]
, and the sum
of this array is equal to 3 + 2 + 1 + 4 + 7 = 17
.
Constraints:
1 <= n <= 2000
1 <= l[i] <= 3000
for all0 <= i < n
Try it yourself
Solution
Title
Script
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Contrary to popular belief, Lorem
Ipsum
is not simply random text.
1 >>> a = [1, 2, 3] 2 >>> a[-1] 3 3