You are given a binary string of length 8

(Example:- 10001010)

Assume the string is written in circular fashion.

(Letâ€™s say we start at the first element of our example string which is 1. The element right after the first element is the second element which is 0 and so on until we get to the 8th element. As the string is circular, this means that the element right after the 8th element (0) is the first element which is 1. )

Count the number of transitions from 0 to 1 or 1 to 0.

(Start from an element in the string and if the next element is different then it counts as a transition.

In our example string, there are 6 transitions.

1->2

4->5

5->6

6->7

7->8

8->1)