So, I used a quick sort to implement the problem in Java. It works fine for the given input set but gives wrong answer. Can someone help me please???
asked 31 May '12, 12:46

You Picked the question in the wrong way. The question is straight forward You just have to sort the given dataset in ascending order. But after analyzing your code ,i think you misunderstood that only one copy of the repeated members is to be printed . No ,that's not the case . And here is the proof ,For the test case
your code was generating the following output
Clearly you were avoiding the printing of repeated members. In order to fix it : Just comment the three lines in printing steps as shown :
answered 31 May '12, 16:46
2
@avengee  "print given numbers in non decreasing order.". u considered it as strictly non decreasing order I guess. @ritesh_gupta is correct , that's the only bug ,your quick sort looks absolutely fine .
(31 May '12, 17:01)
@ritesh_gupta: Thank you so much for the help. I didn't submit yet because I have a small question. So, in nondecreasing order an element can be either equal or greater than the previous element? My question is with the example input and output set in the problem statement: Example Input: 5 5 3 6 7 1 Output: 1 3 5 6 7 This example has avoided repeated numbers. What is it? Or am I still mistaken about the definition of nondescending numbers?
(31 May '12, 19:09)
@avengee: first number is not from the sequence, it is the sequence length ;)
(31 May '12, 19:11)
@avengee :Read the problem statement once again,especially "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]". So the First line 5 means there are 5 elements in the data set and these 5 elements are 5 3 6 7 1 .So our task is to sort the numbers 5 3 6 7 1
(01 Jun '12, 01:48)
Thanks all:). I'm a new coder and sometimes I get so confused:). Thank you again for taking your valuable time to help me out for this simple question:).
(02 Jun '12, 08:11)
pleasure:)
(02 Jun '12, 16:29)
showing 5 of 6
show all

Try the input
the correct answer is
you propably misunderstood Two hints to you:
answered 31 May '12, 13:41
@belista: Thank you for your valuable tips. As I previously stated in the comment for above post, I'm confused with the example. Any help is greatly appreciated:).
(31 May '12, 19:15)
I replied in ritesh_gupta's answer. Above or below is relative, answers are ordered by decreasing number of up votes and despite of that I answered first and ritesh_gupta copied answer 3 hours later he got more up votes...
(31 May '12, 19:22)
Anyways, thank you again:)
(02 Jun '12, 08:11)

include <stdio.h>int v[1000001]={0}; int main() { int n,i,a; scanf("%d",&n); for (i=0;i<n; i++){ scanf("%d",&a); v[a]++; } for (n=0;n<=1000000; n++) for (i=0;i<v[n];i++) printf("%dn",n); return 0; } i am getting wrong answer on this code. please someone help. answered 10 May '13, 10:54
