Skip to content

Instantly share code, notes, and snippets.

@rahulkmr
Created February 7, 2010 07:43
Show Gist options
  • Save rahulkmr/297294 to your computer and use it in GitHub Desktop.
Save rahulkmr/297294 to your computer and use it in GitHub Desktop.
int missing(int a[], int n) {
double num = n + 1;
double ideal_sum = (num * (num + 1)) / 2;
int sum = 0;
int i;
for (i = 0; i < n; i++) {
sum += a[i];
}
return ideal_sum - sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment