Let the glass be numbered 0 1 2 3... (2n - 1).
And the glass numbered 0 1 2 3...(n - 1)  are filled.
Pick every alternating ith filled glass starting from 1 indexed glass and
swap it with the (n - 1 - i)th unfilled glass.

Index 1 will swap with 2n - 2 indexed glass.
Index 3 will swap with 2n - 4 indexed glass.
.
.
.
So on.

Since the first glass is filled and there are 2n glasses(last glass being
indexed by 2n - 1) so the second glass (2n - 2 indexed glass) from the end
must be filled after processing.

On Tue, Nov 6, 2018, 16:24 mehmet ozturk <[email protected] wrote:

> There are 2n glasses standing next to each other in a row, the first n of
> them are filled with
> a soda drink, while the remaining n glasses are empty. Make the glasses
> alternate in a filledempty-
> filled-empty pattern in the minimum no of glass moves.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

Reply via email to