You have two rows of marbles. Each marble has one of three colors: red ('R'), green ('G') or blue ('B'), and no two adjacent marbles have the same color. Rows are not circular, so the first marble in a row is not adjacent to the last.
You are given the Strings colors1 and colors2 representing the colors of the marbles from left to right of each row, respectively. You are allowed to perform exactly one swap operation, where you select one marble from each row and physically swap them. Return the number of different swap operations that result in each row containing three adjacent marbles with the same color. Note that the three adjacent marbles within each row must have the same color, but that color does not necessarily have to be the same between the two rows (see examples).
|