Works fine on eclipse but test case 1 and 2 show run error

import java.util.*;

public class MultipleInContinuousSubarray {

public static void main(String[] args) {
	Scanner scn=new Scanner(System.in);
	
	String s=scn.next();
	s=s.substring(1,s.length()-1);
	String[] str=s.split(",");
	int[] arr=new int[str.length];
	
	for(int i=0;i<str.length;i++) {
		arr[i]=Integer.parseInt(str[i]);
	}
	
	int k=scn.nextInt();
	System.out.println(checkSubarraySum(arr,k));
}

public static boolean checkSubarraySum(int[] nums,int k) {
	if(nums.length==0) {
		return false;
	}
	
	Map<Integer,Integer> map=new HashMap<Integer,Integer>();
	map.put(0,-1);
	
	int sum=0;
	
	for(int i=0;i<nums.length;i++) {
		
		sum+= nums[i];
		if(k!=0) {
			sum=sum%k;
		}
		
		if(map.containsKey(sum)) {
			int prevIndex=map.get(sum);
			if(i-prevIndex>1) {
				return true;
			}
		}else {
			 map.put(sum,i);
			 
		}
	}
	return false;
	
	
}

}

I hope this works.

now all test cases are showing wrong answer

try printing ‘True’ and ‘False’ instead of ‘true’ and ‘false’

still the same run error

are you sure you are submitting this code ? because i ran this code individually on all cases, and it runs correctly.

otherwise send me the link to question

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.