Problem
Ask
Submissions

Problem: Minimum String Length After Removing Substrings

Medium
30 min
Explore how to process a string containing only uppercase letters by repeatedly removing substrings AB and CD until no more removals are possible. Learn to apply stack data structures for this string manipulation task, enabling you to compute the shortest string length after all operations are done. This lesson builds your skills in understanding iterative substring removals and using stacks effectively.

Statement

You are given a string, s, containing only uppercase English letters. You can perform operations on this string where, in each operation, you remove any occurrence of the substrings "AB" or "CD" from s.

Your task is to return the shortest string length after applying all possible operations.

Note: After each removal, the string joins back together, potentially creating new occurrences of "AB" or "CD" that can also be removed.

Constraints:

  • 11 \leq s.length 100\leq 100

  • s consists only of uppercase English letters.

Problem
Ask
Submissions

Problem: Minimum String Length After Removing Substrings

Medium
30 min
Explore how to process a string containing only uppercase letters by repeatedly removing substrings AB and CD until no more removals are possible. Learn to apply stack data structures for this string manipulation task, enabling you to compute the shortest string length after all operations are done. This lesson builds your skills in understanding iterative substring removals and using stacks effectively.

Statement

You are given a string, s, containing only uppercase English letters. You can perform operations on this string where, in each operation, you remove any occurrence of the substrings "AB" or "CD" from s.

Your task is to return the shortest string length after applying all possible operations.

Note: After each removal, the string joins back together, potentially creating new occurrences of "AB" or "CD" that can also be removed.

Constraints:

  • 11 \leq s.length 100\leq 100

  • s consists only of uppercase English letters.