A geek once visited a magical island where he found a special creature. He named it as Smurf. He noticed a very strange thing there. The smurfs resembled the primary colors of light. To make it more clear, the primary colors of light are Red, Green, and Blue. He talked to one of the smurfs. The smurfs came to know that he is a good programmer. The smurfs suggested a deal that they will ask him one question and if he is able to answer that question, they will allow the geek to take anything from the island.
The question is as follows:
The smurfs possess a very magical property. When two smurfs of different colors meet with other, they gets converted into a smurf of the third color. How many minimum number of smurfs will be remaining after this transformation? The question looked simple to geek. However, the smurfs put another constraint to make the geek think more. The two smurfs must be adjacent to each other to make the transformation take place.
The first line contains the number of test cases. The next line represents the total number of smurfs in the island. The next line contains colors of smurfsstanding in a queue. Colors of smurfs will be represented by a single character R, G and B.
Each line in output represents the minimum number of smurfs after transformation corresponding to each test case.
1 <=T<= 50
1 <=N<= 1000
R G B R B
R R G
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.