Created
February 7, 2010 07:43
-
-
Save rahulkmr/297294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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