TURBO SORT solution in C language.- Codechef
TURBO SORT
Problem Code: TSORT
Given the list of numbers, you are to sort them in non decreasing order.
Input
t – the number of numbers in list, then t lines follow [t <= 10^6].
Each line contains one integer: N [0 <= N <= 10^6]
Output
Output given numbers in non decreasing order.
Example
Input:
5 5 3 6 7 1
Output:
1 3 5 6 7
. . .
Solution in C Language.
#include <stdio.h>
int main() {
int t, i;
int a[1000001] = {0};
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
a[n]++;
}
for(i=0;i<1000001;i++){
while(a[i]>0){
printf("%d\n",i);
a[i]--;
}
}
return 0;
}
Click Here To Try Out Above Code :- https://bit.ly/34Lmxsm
Comments
Post a Comment