Let's define a term "RANDOMNESS" of array as...
summation of position of each 1's
for eg
RANDOMNESS for 
(0,0,1,0,1,0,1,1)
will be
23
now calculate max possible RANDOMNESS for the given array (each 1 on max 
possible right position)
here it will be 26

so ans will be-->
MAX RANDOMNESS of given array - RANDOMNESS of given array

On Saturday, June 23, 2012 11:34:55 AM UTC+5:30, zerocool142 wrote:
>
> Given an array containing sequence of bits (0 or 1), you have to sort 
> this array in the ascending order i.e. all 0' in first part of array 
> followed by all 1's.   The constraints is that you can swap only the 
> adjacent elements in the array. Find the minimum number of swaps 
> required to sort the given input array. 
>
> Example:   Given the array (0,0,1,0,1,0,1,1) the minimum number of swaps 
> is 3. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/rugRBg0Q0-kJ.
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