Company: Amazon HackOn
Difficulty: medium
At Elmwood University's annual festival, students hang colourful lights across the main courtyard. The light string has an even number of bulbs, N , with an equal number of green and yellow bulbs. Chris, one of the event organizers, needs to arrange the lights in a visually pleasing alternating pattern. The two acceptable patterns are: starting with a green bulb: G Y G Y ... starting with a yellow bulb: Y G Y G ... To achieve this, Chris can rearrange the string by reversing any segment of consecutive bulbs . He may perform this operation any number of times. Determine the minimum number of segment reversals needed to turn the string into one of these two acceptable patterns. Input Format The first line contains an integer N , the length of the light string. The second line contains a string S of length N consisting only of the characters 'G' (green) and 'Y' (yellow). Output Format Print a single integer — the minimum number of segment reversals required to reach one of the two a