Geek is celebrating holi by aiming coloured water balloons at his friends. He wants to avoid throwing balloons of the same colours more than twice in a row. Given a string st, where each alphabet denotes a different colour, modify the sequenuence to represent the correct order of throwing balloons by eliminating some of them.
Example 1:
Input:
st = ABBBCCDEAB
Output: ABBCCDEAB
Explaination: Remove the third 'B'.
Example 2:
Input:
st = AAAAAA
Output: AA
Explaination: We can keep only two A's.
Your Task:
You do not need to read input or print anything. Your task is to complete the function sequence() which takes string st as input parameter and returns a string containing the modified sequence.
Expected Time Complexity: O(N), where n is the length of the string st.
Expected Auxiliary Space: O(N)
Constraints:
1 ≤ |st| ≤ 10000