Holi Balloons
Submissions: 348   Accuracy:

52.59%

  Difficulty: Easy   Marks: 2

Golu is celebrating holi by throwing water balloons from his balcony at passers-by.This gives him joy and happiness ,but, throwing balloons of same colours more than twice in a row annoys him.Given the initial throwing sequence of balloons , modify the sequence so that Golu don't have to throw balloons of same colours more than twice in a row by eliminating some balloons.Balloons colours are represented by english alphabets -{A-Z}.

Input:

First line of input contains a single integer T denoting the number of test cases. Each test case contains a string S of length N denoting the sequence of N balloons throw.
Output:

For each test case, print the modified sequence in a new line.
Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 10000

Example:

Input:

3
ABBBCCDEAB

HELLO

GEEKFORRRRGEEEK

Output:

ABBCCDEAB

HELLO

GEEKFORRGEEK

** For More Input/Output Examples Use 'Expected Output' option **

Author: Riya Bhardwaj


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.