https://practice.geeksforgeeks.org/problems/binary-array-sorting/0
this is the link of the problem…
my code is :
/*package whatever //do not write package name here */
import java.util.;
import java.lang.;
import java.io.*;
class GFG
{
public static Scanner scn = new Scanner(System.in);
public static void main (String[] args)
{
//code
int t = scn.nextInt();
while(t>0)
{
int n = scn.nextInt();
int[] arr = new int[n];
int i=0;
int j=arr.length-1;
while(i<j)
{
int helper1 = scn.nextInt();
if(helper1==0)
{
arr[i]=helper1;
i++;
}
else if(helper1==1)
{
arr[j]=helper1;
j–;
}
}
for(int p=0; p<arr.length; p++)
{
System.out.print(arr[p] + " ");
}
t–;
}
}
}
if i enter testcases as 3, then only 2 testcases are being read…