# PROBLEM LINK:

**SETTER**: Ashutosh Shaw

**TESTER**: Prasann Kumar Gupta

**Editorialist**: Ashutosh Shaw

# DIFFICULTY:

Easy-Medium

# PREREQUISITE:

greedy

# PROBLEM:

In the problem is given a string containing, ‘c’ or ‘+’. A Complete String is a non-empty string that consists of consecutive occurrences of “c++”, any number of times.

You can form a Complete String *(if possible)* by removing some of the characters from the string *(possibly 0)*. Your task is to remove **minimum** number of the characters from the string *(possibly 0)*, such that no Complete String can be formed from the resulting string.

# EXPLANATION:

We need to eliminate all the possibility of subsequences having consecutive occurrences of “c++”. This implies that there should not be more than one ‘+’ after any ‘c’; there should be zero occurrences of ‘c’ before any two '+'s. Hence what we can do is, for every ith position, we can delete all the 'c’s from 1^{st} to (i-1)^{th} position and all the '+'s (except 1) from the i^{th} to the last position in the string (only if there are more than one ‘+’). Then, take the minimum of all the positions.

# TIME COMPLEXITY:

O(n)

# SOLUTIONS:

## Setter's Solution

## Tester's Solution

Feel free to share your approach. Suggestions are welcomed as always.