We are loading a container ship with a single crane. The containers are on the
dock, adjacent to each other in a line. Each container is owned by one of
our 4 customers. We need to rearrange them so that the containers are still
in a line with no gaps located somewhere on the dock, with each customer's containers
adjacent to each other.
We move a container by using our crane to pick up a single container and place
it somewhere on the dock (but not on top of another container). The problem is
to minimize the number of moves.
The String containers shows the original order of the containers, with each
container appearing as 'A','B','C', or 'D' according to which of our customers
is the owner. Return the minimum number of moves required.
|