Unable to find the error in the program for the question "Recursion - Subsequence"

My code is giving the wrong answer for all the test cases however I am unable to figure out any error in my code. I am simple printing the subsequence according to the set bits in numbers from 0 to 2^N. Please Help!

Here is my code: https://ide.codingblocks.com/s/299110

@Yash5646 what problem are you facing?

All the test cases are giving an wrong answer. But I can’t find anything mistake in my logic.

hi @Yash5646 i manually downloaded the output files for test cases, and there is a small spacing issue. You are printing an extra space at the end of all permutations (in the first line of output) and you are getting WA due to that. (you can see your output on the right, has an additional space.)

I made the " " the prefix of the string I am printing, still I am getting a WA error.
Here is the new code : https://ide.codingblocks.com/s/299110

@Yash5646 its printing 4 spaces now at the end.

Got it thanks alot!!

1 Like