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
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Remove all consecutive duplicates from the string
- Remove three consecutive duplicates from string
- Remove consecutive vowels from string
- Python groupby method to remove all consecutive duplicates
- Lower case to upper case - An interesting fact
- Count of alphabets having ASCII value less than and greater than k
- Program to generate random alphabets
- Check if words are sorted according to new order of alphabets
- 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]
- Maximum distinct lowercase alphabets between two uppercase
- Sub-string that contains all lowercase alphabets after performing the given operation
- Count of character pairs at same distance as in English alphabets
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.