Can use counting sort for this problem... ids<=650000
Problem statement clarification:
Now I get it, I was misinterpreting question all thi...
The question does not clearly state what we have to do actually.