Remove b and ac from a given string
Easy Accuracy: 64.71% Submissions: 2792 Points: 2

Given a string, eliminate all “b” and “ac” in the string, replace them in-place and iterate over the string once.

Example 1:

Input: str = "aacbacc"
Output: ac
Explanation: Iterate once and remove
occurrence of "b" and "ac"

Example 2:

Input: str = "aacb"
Output: a
Explanation: Iterate once and remove
occurrence of "b" and "ac"

Your task:
Your task is to complete the function stringFilter() which takes a single string as input and returns the string. You need not take any input or print anything.
 

Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(1)

Constraints:
1 <= |S| <= 105

String contains lower case alphabets

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Remove b and ac from a given string

Output Window