int n = A.size();
for (int i=0; i<n; i++)
total += A[i];
findMinMax(A[1...n]);
int mean = (max+min)/2;
if ((total - n*mean) == 0)
printf("consecutive\n");
else
printf("not consecutive\n");
findMixMax() ... this can be done in O(n)
so, total time complexity ... O(n)
works for negative numbers also.... if there is any mistake ... let me
know
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.