import java.util.Scanner;
public class Main {
public static void kadane(int [] arr)
{
int maxsum=0;
int cur_sum=0;
for(int i=0;i<arr.length;i++)
{
cur_sum+=arr[i];
if(cur_sum<0)
{
cur_sum=0;
}
if(cur_sum>0)
{
maxsum=cur_sum;
}
}
System.out.println(maxsum);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int testcases=sc.nextInt();
while(testcases>0)
{
int n=sc.nextInt();
int [] arr= new int[n];
for(int i=0;i<n;i++)
arr[i]=sc.nextInt();
kadane(arr);
testcases–;
}
}
}
Can someone tell me what is the problem in this code?