Skip to content

Instantly share code, notes, and snippets.

@rahulkmr
Created February 7, 2010 07:44
Show Gist options
  • Save rahulkmr/297296 to your computer and use it in GitHub Desktop.
Save rahulkmr/297296 to your computer and use it in GitHub Desktop.
int get_max_range(int a[], int n, int *start, int *end)
{
int temp_sum = 0, sum = 0, found = -1;
int i, j;
for (i = 0; i < n - 1; i++) {
temp_sum = a[i];
*start = i;
for (j = i;j < n; j++) {
temp_sum = a[j];
if (temp_sum > sum) {
sum = temp_sum;
found = 1;
*end = j;
}
}
}
return found;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment