My issue
Array Index Out Of Bounds Exception
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.ArrayList;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
int t,n,j;
Scanner sc= new Scanner(System.in);
t=sc.nextInt();
n=sc.nextInt();
int a[]=new int[n];
ArrayList<Integer> b=new ArrayList<>();
for(int i=0;i<t;i++)
{
for( j=0;j<n;j++)
{
a[j]=sc.nextInt();
}
String v=sc.next();
int arr[]=new int[v.length()];
for(int k=0;k<v.length();k++)
{
arr[k]=Character.getNumericValue(v.charAt(k));
}
for(int m=0;m <n;m++)
{
if(arr[m]==0)
b.add(a[m]);
}
Collections.sort(b);
System.out.println(b.get(0));
}
}
}
Learning course: Placement preparation using Java
Problem Link: Practice Problem in - CodeChef