What is wrong in this code

#include
using namespace std;
void counting( int *a, int n){
int largest=-1;
for( int i=0;i<n;i++){
largest=max(largest,a[i]);
}
int *freq= new int[largest+1]{0};
for( int i=0;i<n;i++){
freq[a[i]]++;
}
int j=0;
for( int i=0;i<=largest;i++){
while(freq[i]>0){
a[j]=i;
freq[i]–;
j++;
}
}
}
int main(){
int n,a[1000000];
cin>>n;
for( int i=0;i<n;i++){
cin>>n;
}
counting(a,n);

	for( int i=0;i<n;i++){
	cout<<a[i]<<" ";
}

return 0;

}

hi @shikhasood0810 please share your code using cb ide

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.