Counting Sort Problem

de
using namespace std;
int main() {

int n;
cin>>n;

int arr[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}

int freq[100005]={0};

for(int i=0;i<n;i++)
{
	freq[arr[i]]++;
}

for(int i=0;i<100005;i++)
{
	for(int j=0;j<freq[i];j++)
	{
		cout<<i<<" ";

	}
}
return 0;

}

Maximum value of arr[i] can be 1000006 (10^6 + 6). So the size of our frequency array should be 1000007.

still not wokring please help


Check this

@arsh_goyal Please mark your doubt as resolved if you are satisfied