My issue
Why isn’t this logic not working?
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n=sc.nextInt(),x=sc.nextInt();
int max=x,temp=0;
ArrayList<Integer> arr=new ArrayList<>();
for(int i=0;i<n;i++){
temp=sc.nextInt();
max=max+temp;
arr.add(max);
}
System.out.println(Collections.max(arr));
}
}
}
Problem Link: Hostel Room Practice Coding Problem - CodeChef