Sorting linear time problem--------------

what;s the error in my code:

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt(), arr[] = new int[n];
for(int i = 0;i<arr.length;i++){
arr[i] = cin.nextInt();
}
int max = 0;
for(int i = 0;i<arr.length;i++){
if(arr[i]>max){
max = arr[i];
}
}
int s[] = sort(arr,max);
for(int t:s){
System.out.println(t);
}
}
public static int[] sort(int arr[], int k){
int count [] = new int[k+1], b[] = new int[arr.length];
for(int i = 0;i<count.length;i++){
++count[arr[i]];
}
for(int i = 0;i<count.length-1;i++){
count[i] = count[i] + count[i+1];
}
for(int i = b.length-1;i>-1;i–){
b[–count[arr[i]]] = arr[i];
}
for(int i = 0;i<arr.length;i++){
arr[i] = b[i];
}
return arr;
}
}

Hi @AbhishekAhlawat1102,
Check for comments in my code to find your errors.

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.