The instruction said that you don't have to allocate memory for the result and instead just have to write to the given pointer. In your solution you are free to allocate whatever you want (keep it under 10GB though ;-)
sidd114, could you please add this information about 'any order' in the description of the kata. Because that was the first question I've got after reading the kata.
seeing that this is one of your first katas on the site, you could try solving easier katas first (7/8kyu) and then move to more complex ones like these.
p.s., this is not a kata issue
EDIT: the tests are framed in a way such that you can return the powerset in any order. the test suite will sort it for you
Useless for me, simply because requirements are incomplete.
The test expects a list with a specific order and the order has nothing to do with (sub)sets.
And there is no specific requirement defining precisely any specific order.
The instruction said that you don't have to allocate memory for the
result
and instead just have to write to the given pointer. In your solution you are free to allocate whatever you want (keep it under 10GB though ;-)sidd114, could you please add this information about 'any order' in the description of the kata. Because that was the first question I've got after reading the kata.
seeing that this is one of your first katas on the site, you could try solving easier katas first (7/8kyu) and then move to more complex ones like these.
p.s., this is not a kata issue
EDIT: the tests are framed in a way such that you can return the powerset in any order. the test suite will sort it for you
Focused on performance. The square root value may be hardcoded but modern compiler will eliminate it anyway.
Useless for me, simply because requirements are incomplete.
The test expects a list with a specific order and the order has nothing to do with (sub)sets.
And there is no specific requirement defining precisely any specific order.
The shortest solution I was able to think of without using libraries.
But this one allocates memory (strdup), while instruction ordered to avoid it.