Sorting in o(n)

mport java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for(int i=0;i<arr.length-1;i++){
arr[i] = sc.nextInt();
}
int low = 0;
int high = arr.length-1;
int mid = 0;
int temp;
while(mid<=high){
if(arr[mid] == 0){
temp = arr[low];
arr[low] = arr[mid];
arr[mid] = temp;
mid++;
low++;
}else if(arr[mid] == 1){
mid++;
}else{
temp = arr[high];
arr[high]= arr[mid];
arr[mid] = temp;
high–;
}
}
}
}

@discobot Tell me the problem you’re facing

Hi! To find out what I can do, say @discobot display help.

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.