Split String – Continuous Repetition

Split String – Continuous Repetition: The program must accept a string S as the input. The program must split the string into multiple substrings based on the following condition.
– If a character has repeated continuously even number of times, the program must split the string in the middle of the continuous occurrences of the character.
Finally, the program must print the substrings of S in separate lines as the output.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains S.

Output Format:
The lines containing the substrings of S as per the given condition.

Example Input/Output 1:
Input:
SkillRack

Output:
Skil
lRack

Explanation:
The string S is SkillRack.
The character l is repeated 2 times continuously in S.
So the substrings of S are Skil and lRack.

Example Input/Output 2:
Input:
aabbbbccc

Output:
a
abb
bbccc

Explanation:
The string S is aabbbbccc.
The character a is repeated 2 times continuously in S.
The character b is repeated 4 times continuously in S.
So the substrings of S are aabb and bbccc.

Previous Article

Inviting Customer Count

Next Article

Shift Minimum to End

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *