I think I got an work around for this.... if number of elements are
not odd why not make them odd :)
I variation to my prev algo
int n = A.size();
for (int i=0; i<n; i++)
total += A[i];
findMinMax(A[1...n]); //returns first smallest (fmin), second smallest
(smin) and largest (max) element in array
int fmean = (max+fmin)/2;
int smean = (max+smin)/2;
stotal = total - fmin;
if ((total - n*fmean) == 0)
{
if ((stotal - n*smean) == 0)
printf("consecutive\n");
return;
}
printf("not consecutive\n");
--
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.