int [] a= {1,0,1,0,1,1,1,0,0,0};
int [] arr= new int[a.length];
int left=0; int right=a.length-1;
while (left
7 Answers
int [] a= {1,0,1,0,1,1,1,0,0,0};
int [] arr= new int[a.length];
int left=0; int right=a.length-1;
while (left
public static void main(String[] args) {
int [] a= {1,0,1,0,1,1,1,0,0,0};
int [] arr= new int[a.length];
int left=0; int right=a.length-1;
while (left
public static void main(String[] args) {
int [] a= {1,0,1,0,1,1,1,0,0,0};
int [] arr= new int[a.length];
int left=0; int right=a.length-1;
while (left
int[] a={0,1,0,1,1,1,0,0,0,1};
int index=0;
public static int[] sortBinaryArray(int[] a)
{
for(int i=0;i
public static int[] sortBinaryArray(int[] a)
{
int leftptr=0;
int rightptr=a.length-1;
while(true)
{
while(a[leftptr]==0)
{
leftptr++;
}
while(a[rightptr]==1)
{
rightptr--;
}
if(leftptr
One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.
To comment on this, Sign In or Sign Up.
Would you like us to review something? Please describe the problem with this {0} and we will look into it.
Your feedback has been sent to the team and we'll look into it.
public static void SortBinaryArrays(int[] Binary) {
int[] sorrtedArray = new int[Binary.length];
int i = 0;
for (int a : Binary) {
if (a == 0) {
sorrtedArray[i] = a;
i++;
}
}
for (int a : Binary) {
if (a == 1) {
sorrtedArray[i] = a;
i++;
}
}
for (int a : sorrtedArray) {
System.out.print(a + " ");
}
}