Program to find the largest sum of contiguous integers in
the array. O(n)

Answers were Sorted based on User's Feedback



Program to find the largest sum of contiguous integers in the array. O(n)..

Answer / harsha

Going by the answer 7..

max=0;
sum=0;

for i in 0 .. n
sum = sum + numbers[i];
if( sum > max ) {
max = sum;
}
else if (sum<0) {
sum=0;
}

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More C Code Interview Questions

Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.

2 Answers  


What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;

1 Answers  


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }

3 Answers   Accenture,


main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

3 Answers  


write a program in c language to get the value of arroy keys pressed and display the message which arrow key is pressed?

1 Answers  


main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }

2 Answers  


void main() { int c; c=printf("Hello world"); printf("\n%d",c); }

2 Answers  


int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }

1 Answers  


Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.

5 Answers   IITR, Microsoft, Nike,


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


program to Reverse a linked list

12 Answers   Aricent, Microsoft, Ness Technologies,


Categories