Your Second approach is cool :)

On Wed, Dec 22, 2010 at 1:06 PM, juver++ <[email protected]> wrote:

> Use bits manipulation tricks.
> 1. There is a way to remove a group of consecutive 1's from the right: A =
> n & (n + 1). Then check if A==0 then OK.
> 2. Second approach: B=n+1, check if B & (B-1) (this checks if B is a power
> of 2, so it contains only 1 set bit) is zero then OK.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
B. Praveen

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to