In Code Melange (Rated) contest problem, Xorangements problem giving WA to my solution

In Code Melange (Rated) contest problem, Xorangements giving WA to my solution
According to me, my Code is passing all test cases… can anyOne give any test case in which my program is getting failed
and if anyOne come to know why my program getting failed, that reason will be bonus…
thanks in Advance

Problem link In practice section
MySolution LInk

For test case 1 11 .
Your code gives -1.
But correct answer is 3 2 6 7 5 4 0 1 9 8 10.And other combinations.

P.S. - I’m still waiting for the editorials.

I have devised a neat, fast method of solution, which requires no clever algorithms or data structures, not even an array.

Start with the largest number to be printed = N - 1.

Identify the index of the last binary 1, counting from 0 at the right.

Loop until no more 1s of the original number are left:

Change the identified 1 to a 0.

If this is the last digit (index 0), write the number.

Else work down recursively, starting one index down - at each index, if reached the last digit write the number, swap the last digit 0 to 1 or 1 to 0, and write the number again. Else call recursively, with the index of the digit reduced by 1, swap the digit at the current index, and call recursively again with the index again reduced by 1.

Identify the index of the next last binary 1 in the original number, taking care not to disturb later digits which may have been changed during the recursive calls.

Example - given decimal 11, output 10 8 9 1 0 2 3 7 6 4 5 = binary 1010 1000 1001 1 0 10 11 111 110 100 101

My solution (in C) is at CodeChef: Practical coding for everyone