Unique Twitter User Id Set
Example
Example:
Input:
arr = [3, 2, 1, 2, 7]
output: 17
Explanation:if arr = [3, 2, 1, 2, 7], then arr(unique) = [3, 2, 1, 4, 7] and its user ids sum to a minimal value of 3 + 2 + 1 + 4 + 7 = 17class Solution:
"""
@param arr: a integer array
@return: return ids sum is minimum.
"""
def UniqueIDSum(self, arr):
# write your code here
res = low = 0
arr.sort()
for i in arr:
low = max(low,i)
res+=low
low+=1
return res Last updated