{}
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
Main.java
class Sortarray { public static void main(String[] args) { int arr[]={0,1,1,0,0,1,0,1,0,0}; int n=arr.length; int i=0; int j=n-1; while(i<j){ if(arr[i]==0) i++; else if(arr[j]==1) j--; else if(arr[i]==1 && arr[j]==0){ arr[i]=0; arr[j]=1; } } for(int ele:arr){ System.out.print(ele+" "); } } }
Output