Given a string. Write a program to remove all the occurrences of a character in the string.
Input : s = "geeksforgeeks" c = 'e' Output : s = "gksforgks" Input : s = "geeksforgeeks" c = 'g' Output : s = "eeksforeeks"
The idea is to maintain an index of resultant string.
Time Complexity : O(n) where n is length of input string.
Auxiliary Space : O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Map every character of one string to another such that all occurrences are mapped to the same character
- Replace all occurrences of character X with character Y in given string
- Remove all occurrences of a character in a string | Recursive approach
- Number of permutations of a string in which all the occurrences of a given character occurs together
- Check if all occurrences of a character appear together
- Minimize ASCII values sum after removing all occurrences of one character
- Print the string by ignoring alternate occurrences of any character
- Count occurrences of a character in a repeated string
- Remove all occurrences of any element for maximum array sum
- Remove duplicates from string keeping the order according to last occurrences
- Smallest string obtained by removing all occurrences of 01 and 11 from Binary String
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Find the number of occurrences of a character upto preceding position
- Replace all occurrences of string AB with C without using extra space
- Replace all occurrences of pi with 3.14 in a given string
- Replace all occurrences of a string with space
- Swap all occurrences of two characters to get lexicographically smallest string
- Sum of all distances between occurrences of same characters in a given string
- Recursive program to replace all occurrences of pi with 3.14 in a given string
- Count occurrences of a string that can be constructed from another given string
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.