This was the code compiled by me, and it was showing correct output, But while submitting in Coding Blocks IDE, it showed error.
Can you figure out the error in the following code.
Else, Provide me the code with explaination as well.
#include
using namespace std;
int main()
{
int number;
// cout<<"Enter the number of arrays: ";
cin >> number;
int size;
int arr[1000];
int currentSum = 0;
int maximumSum = 0;
for(int i = 0; i < number;i++)
{
cin >> size;
for (int j = 0; j < size; j++)
{
cin >> arr[j];
}
// Kadane's Algorithm for Maximum Sub-Array Sum
for(int i =0; i<size; i++)
{
currentSum = currentSum + arr[i];
maximumSum = max(currentSum,maximumSum);
}
cout << maximumSum << endl;
}
return 0;
}