Can someone explain the problem? I did not understand how the answer for test case - 1 7 8 -8 9 -9 10 -11 12 is 22.
Maximum circular sum
You have to consider the given array to be circular. And hence find maximum sum of subarray.
In given sample input,
1
7
8, -8, 9, -9, 10, -11, 12
here 1 is number of test cases being considered. 7 is number of elements in array.
We get maximum sum when we consider subarray from 12 to 10, i.e, 12+8+(-8)+9+(-9)+10=22.
You need to consider the first element after the last in array as it is circular …
Got it, thanks!
…
question link
https://online.codingblocks.com/player/11915/content/5302?s=1502
my code
https://ide.codingblocks.com/s/43032
why it is displaying garbage value
Do add the problem link.This question link is not visible to me but only you.
And you have declared a[i], without taking the input for " i".
There may be some other problems ,If u provide me the right question link than I can tell you further.
MAXIMUM CIRCULAR SUM
You are provided n numbers (both +ve and -ve). Numbers are arranged in a circular form. You need to find the maximum sum of consecutive number.
Input Format:
First line contains integer t which is number of test case. For each test case, it contains an integer n which is the size of numbers and next line contains n space separated integers.
Constraints:
1<=t<=100 1<=n<=1000
Output Format
Print the maximum sum.
Sample Input
1
7
8 -8 9 -9 10 -11 12
Sample Output
22
@anitagupta1411
The link of code " https://ide.codingblocks.com/s/43032 " that you have provided does not belong to
ARRAYS-SPIRAL PRINT ANTICLOCKWISE. Please do check