Ishaan is playing with strings these days. He has found a new string. He wants to modify it as per the following rules to make it valid:
Find the minimum number of characters which Ishaan must insert in the string to make it valid.
The first line of input contains a single integer T denoting the number of test cases. The only line of each test case contains a string S consisting of lowercase English Alphabets.
For each test case, in a new line, print the required answer in a new line.
This is a function problem. You only need to complete the function modified that returns the answer.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
1 <= T <= 100
1 <= Length of S <= 105
Testcase 1: In aabbbcc 3 b's occur consecutively, we add a 'd',and Hence, output will be aabbdbcc.
Testcase 2: In aaaaa 5 a's occur consecutively, we need to add 2 'b', and Hence, the output will be aababaa.
Testcase 3: In abcddee, No character occurs 3 times, so no need to add anything.
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.