[algogeeks] Re: 1s and 0s

2010-12-27 Thread awesomeandroid
your first approach is totally correct. On Dec 22, 12:36 pm, juver++ avpostni...@gmail.com 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

Re: [algogeeks] Re: 1s and 0s

2010-12-26 Thread 王大东
bits manipulation tricks is cool to solve these kind of questions. On Sun, Dec 26, 2010 at 3:27 PM, Praveen Baskar praveen200...@gmail.comwrote: Your Second approach is cool :) On Wed, Dec 22, 2010 at 1:06 PM, juver++ avpostni...@gmail.com wrote: Use bits manipulation tricks. 1. There is a

Re: [algogeeks] Re: 1s and 0s

2010-12-25 Thread Praveen Baskar
Your Second approach is cool :) On Wed, Dec 22, 2010 at 1:06 PM, juver++ avpostni...@gmail.com 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)

Re: [algogeeks] Re: 1s and 0s

2010-12-22 Thread Carl Barton
Could be modelled as a deterministic finite statemachine to be checked in linear time. On 22 December 2010 07:47, snehal jain learner@gmail.com wrote: @above nice approach :) On Wed, Dec 22, 2010 at 1:06 PM, juver++ avpostni...@gmail.com wrote: Use bits manipulation tricks. 1. There

Re: [algogeeks] Re: 1s and 0s

2010-12-22 Thread Anand
http://anandtechblog.blogspot.com/2010/12/sort-array-containing-1s-and-0s.html On Wed, Dec 22, 2010 at 6:47 AM, Carl Barton odysseus.ulys...@gmail.comwrote: Could be modelled as a deterministic finite statemachine to be checked in linear time. On 22 December 2010 07:47, snehal jain

Re: [algogeeks] Re: 1s and 0s

2010-12-22 Thread Carl Barton
This is simply a decision problem is it not? the above sorting would require n log n for comparison sorting where as a decision could be simply done in linear time and space. Please correct me if i'm wrong On 22 December 2010 19:17, Anand anandut2...@gmail.com wrote:

Re: [algogeeks] Re: 1s and 0s

2010-12-22 Thread juver++
Problem mentioned by @investmentsupergro...@googlegroups.com is not connected with the original problem. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this

[algogeeks] Re: 1s and 0s

2010-12-21 Thread juver++
Use bits manipulation tricks. There is a way to remove a group of consecutive 1's from the right: A = n (n - 1). Then check A==0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: 1s and 0s

2010-12-21 Thread snehal jain
@above nice approach :) On Wed, Dec 22, 2010 at 1:06 PM, juver++ avpostni...@gmail.com 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