## Interview Question

Test Automation Engineer Interview

-Bangalore

# Sort Binary Arrays - {0,1,0,1,1,1,0,0,0,1}

3

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 + " "); } }

Keshav Sharma on

0

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

Shabana Khan on

0

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

Anonymous on

2

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

Learner on

0

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

Learner on

1

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

xyz on