Problem hidden
NINJAREV3 - THREE
Debug the following code:
int sum(int arr[],int n)
{
int a=0;
int b=0,c;
for(int i=1;i<n;i++)
{
c=min(a,b);
a=b;
b=c;
}
return max(a,b);
}
Input :
The first line has an integer T, the number of test cases.
Then for each test case, the first line indicates the no: of elements in an array. Second line denotes the elements of the array
Output:
An integer
Sample input
2
3
86 77 15
3
35 86 92
Sample output:
101
127
Added by: | mombassa |
Date: | 2016-02-18 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |