Could be modelled as a deterministic finite statemachine to be checked in
linear time.


On 22 December 2010 07:47, snehal jain <[email protected]> wrote:

> @above
> nice approach :)
>
>
> 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.
>>
>
>  --
> 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.
>

-- 
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