The set of written test questionquestion1:adjustment Queue
- In the Kindergarten,there is N children arranged in a team,with one number from left to right (0~n-1). Some of them is Boys,some is girl,boys is represented by ' B ', and girls is indicated by ' G '. The children was very naughty,and when a boy was squattion with a girl,there would be contradiction. As a kindergarten teacher,you need to let the boys take the girls or girls to the least. You CNA only make Adjustmentson the original formation. Each adjustment can is only allow the adjacent Childrento exchange positions. Now you need to complete the team adjustment as soon as possible. You need to calculate the minimum number of adjustments you need to make the situation the least. For EXAMPLE:GGBBG->GGBGB->GGGBB
This would make the previous-male and female neighbors become adjacent,and need to adjust the formation 2 times.
Enter a Description:
The input data includes a string of length n and containing only G and B.N does not exceed 50.
Output Description:
Output an integer indicating the minimum number of adjustments required for the team.
Input Example:
Output Example:
2
C + + question