Re: [algogeeks] Minimal number of swaps

2016-03-29 Thread Régis Bacra
[index] != 1 >> count ++ >> end >> end >> >> The variable "count" indicates the minimum number of steps required to >> obtain a sorted list. >> >> >> On 29 March 2016 at 19:30, Régis Bacra <fredericd...@g

[algogeeks] Minimal number of swaps

2016-03-29 Thread Régis Bacra
This puzzle comes from a contribution on codingame.com (link to the puzzle ). Any idea to solve it efficiently? Given a list of 1 and 0, you must regroup all the 1 at the begin of the list in a minimum number of steps. A step is the