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 consecutive vowels from string
- Remove three consecutive duplicates 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
- 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
- Maximum distinct lowercase alphabets between two uppercase
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Check if words are sorted according to new order of alphabets
- Check if a string contains only alphabets in Java using ASCII values
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.