i applied kadane’s algo on every rotation of array and printed the maximum one , can you please tell me my mistake , its not clearing 3 test cases out of 5;
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int t= s.nextInt();
for(int j =0;j<t;j++){
int n =s.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++){
arr[i] =s.nextInt();
}
int tmax =0;
for(int l =1;l<n;l++){
leftRotate(arr,l,n);
int max =0;
int sum =0;
for(int i=0;i<n;i++){
sum = sum+ arr[i];
if(sum<0){
sum=0;
}
if(max<sum){
max = sum;
}
}
if(max>tmax){
tmax =max;
}
}
System.out.println(tmax);
}
}
public static void leftRotate(int arr[], int d, int n)
{
for (int i = 0; i < d; i++)
leftRotatebyOne(arr, n);
}
public static void leftRotatebyOne(int arr[], int n)
{
int i, temp;
temp = arr[0];
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];
arr[i] = temp;
}
}