Adobe Interview Question
Software Engineer / Developersint arr[SIZE]={12,34,32,-101,23,45,32,-56};
int maxsum=0;
int start=0;
int end=0;
int rec =0; int currentsum=0;
for( int i=0;i<SIZE;i++)
{
currentsum+=arr[i];
if(currentsum>maxsum)
{
maxsum=currentsum;start=rec; end=i;
}
else if(currentsum<0){
rec=i+1;
currentsum=0;
}
}
printf("max sum =%d", maxsum);
printf("\n indexes =%d,%d", start,end);
max sum of rows u mean?
- Anonymous November 02, 2010