Given a string str, the task is to remove consecutive characters from the string that are in same case (Uppercase or Lowercase) and print the resultant string.
Input: str = “GeeksForGeeks”
Input: str = “abcDEFghi”
- Print the first character as it is.
- Traverse through all the other characters in the string starting from second character.
- Compare the current and the previous characters:
- If the current and the previous characters are in the same case then skip.
- Else print the current character.
Below is the implementation of the above approach:
- Remove all characters other than alphabets from string
- Remove three consecutive duplicates from string
- Remove all consecutive duplicates from the string
- Remove consecutive vowels from string
- Python groupby method to remove all consecutive duplicates
- Lower case to upper case - An interesting fact
- Program to generate random alphabets
- Count of alphabets having ASCII value less than and greater than k
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Count and Print the alphabets having ASCII value in the range [l, r]
- Sub-string that contains all lowercase alphabets after performing the given operation
- Check if words are sorted according to new order of alphabets
- Maximum distinct lowercase alphabets between two uppercase
- Count of character pairs at same distance as in English alphabets
- Check if a string contains only alphabets in Java using Lambda expression
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.