Re: [algogeeks] Re: Subset Generation

2012-02-10 Thread shady
answer is always +ve, does anyone know how to code it ? On Sat, Feb 11, 2012 at 11:37 AM, Tushar tushicom...@gmail.com wrote: for the given test case in the problem, answer could have been zero what does it mean by without even reading zero in the problm statement? On Feb 9, 11:34 pm,

[algogeeks] Re: Subset Generation

2012-02-10 Thread Dave
@Shady: I'd try something like this: For each n: Let m = the number of 1-bits in n. If k = 1m, then output -1. For i = 1 to m do Replace the ith 1-bit of n (counting from the right) with the ith bit of k. Output the updated n. Example: n = 27 = binary 11011, k = 5 = binary 00101: m = 4.

[algogeeks] Re: Subset Generation

2012-02-10 Thread Dave
@Dave: Oops. The last line of the example should be Output 9. Dave On Feb 11, 1:39 am, Dave dave_and_da...@juno.com wrote: @Shady: I'd try something like this: For each n: Let m = the number of 1-bits in n. If k = 1m, then output -1. For i = 1 to m do     Replace the ith 1-bit of n