📅  最后修改于: 2022-03-11 14:48:23.841000             🧑  作者: Mango
int sumOfDistinct(int a[], int n){
int sum = 0;
for (int i = 0; i < n; i++) {
// If element appears first time
if (a[abs(a[i]) - 1] >= 0) {
sum += abs(a[i]);
a[abs(a[i]) - 1] *= -1;
}
}
return sum;