Counting Sort tle

My code is showing time limit error

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i=0,j=0;
int a[]=new int [n];
for(i=0;i<n;i++)
a[i]=sc.nextInt();
int c=a[0];
for(i=0;i<n;i++){
if(a[i]>c)
c=a[i];}
int b[]=new int [c+1];
for(j=0;j<=c;j++)
{
b[j]=0;
for(i=0;i<n;i++){
if(a[i]==j)
b[j]++;}
}
int as[]=new int[n];
j=0;
for(i=0;i<=c;i++)
{

        while(b[i]!=0 && j<n)
        
        {

            as[j]=i;
            
            b[i]--;
            System.out.print(as[j] + " ");
            j++;
        }
    }

        }

}

HI @rheachhabra1011 ,
Your code is showing TLE probably due to the two for loops after declaring array ‘b’. Your sort algorithm is supposed to run in linear time. Instead of comparing (a[i]==j) you can remove a for loop and just do b[a[i]]++.
And it will be really nice if you can copy the code on coding blocks ide and then share the link.