#include
using namespace std;
int main() {
int n;
cin>>n; //size of array
int a[3],i,p;
for(i=0;i<n;i++)
{
cin>>p;
a[p]++;
}
i=0;
for(i=0;i<3;i++)
{
while(a[i]!=0)
{
cout<<i<<endl;
a[i]--;
}
}
return 0;
}
#include
using namespace std;
int main() {
int n;
cin>>n; //size of array
int a[3],i,p;
for(i=0;i<n;i++)
{
cin>>p;
a[p]++;
}
i=0;
for(i=0;i<3;i++)
{
while(a[i]!=0)
{
cout<<i<<endl;
a[i]--;
}
}
return 0;
}
firstly u have to take size of a upto which u can enter the value
like the value can be upto 10^18 so u cannot declare that much size in array
2nd u have to check array for the last value u have enter and inside this there is a while loop which is printing all occurunce of a value
so time complexity is not o(n)
hope this help:)