Wrong output in "Count number of binary strings" problem

THE CODE IS SAME AS TAUGHT IN LECTURE VIDEO. BUT IT IS PASSING ONLY ONE TEST CASE OUT OF THREE.

import java.util.*;
public class Main
{
public static int BS(int n)
{
int[] ones=new int[n];
int[] zeros=new int[n];
zeros[0]=1;
ones[0]=1;
for(int i=1;i<zeros.length;i++)
{
zeros[i]=zeros[i-1]+ones[i-1];
ones[i]=zeros[i-1];
}
int ans=zeros[n-1]+ones[n-1];
return ans;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for(int i=1;i<=T;i++)
{
int n=sc.nextInt();
System.out.println(BS(n));
}
}
}

@vinay86048,
https://ide.codingblocks.com/s/233016 corrected code

Use long instead of int.

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.