Skip to content

Practice Minimum String Length After Removing Substrings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2696
LeetCode Problem

Minimum String Length After Removing Substrings

Problem Statement

You are given a string s consisting only of uppercase English letters. You can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings "AB" or "CD" from s. Return the minimum possible length of the resulting string that you can obtain. Note that the string concatenates after removing the substring and could produce new "AB" or "CD" substrings.

Source: Minimum String Length After Removing Substrings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "ABFCACDB"
Output
2

# Example 2

Input
s = "ACBBD"
Output
5

Constraints

1 <= s.length <= 100
s consists only of uppercase English letters.

Related LeetCode Problems

Practice more problems similar to Minimum String Length After Removing Substrings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.