sorting problem

in TSORT problem in easy section every time for my programm in c & python time limit exceeded.
give me any suggestion, i will thankful for that

Try to understand Counting sort algorithm. It is very easy to understand and implement and is a linear (O(n)) algorithm. will get accepted in the given time limits

can you make me understand eaisly and in a better way

You don’t need something special, use some standard sorting algorithm from library. Do not implement your own if that is not exactly what you want to do…

Look at qsort for C, I believe there is something similar in python.

1 Like

i tried TSORT question but i am getting wrong answer , please help me,
here is my code

#include <stdio.h>
#include <stdlib.h>

int cmpfunc (const void * a, const void * b)
return ( (int)a - (int)b );

int main()
unsigned int i=0,t,A[1000000];
printf(“enter no of numbers”);

qsort(A, 1000000, sizeof(long int), cmpfunc);

for( i = 0 ; i < t; i++ ) {
printf("%u\n", A[i]);


thank you for your suggestion , i worked on it .but there is a new problem ,please help me agian

@singhisking You should not use any printf statements like “enter number”,“input”,etc. strictly follow the input/output format given. input is automatically taken by your program when you put scanf statements.only print the output numbers.

Remove that printf statement and it gets accepted.

1 Like

i made it,thanks a lot