[algogeeks] 0 and 1 again :)

2010-07-04 Thread jalaj jaiswal
You are given an array ' containing 0s and 1s. Find O(n) time and O(1) space algorithm to find the maximum sub sequence which has equal number of 1s and 0s. Examples 1) 10101010 The longest sub sequence that satisfies the problem is the input itself 2)1101000 The longest sub sequence that

Re: [algogeeks] 0 and 1 again :)

2010-07-04 Thread Nikhil Jindal
Hello Jalaj, I am not sure whether I have understood your approach corectly, but do you want to say that you will always get a subsequence with number of terms equal to twice the min(count0, count1)? Consider for ex: 00 The longest subsequence is 01 or 10, both of length 2(and none of