Minimum String Length After Removing Substrings
Minimize string length by removing 'AB' and 'CD' substrings using stack approach. Traverse string, push chars onto stack, pop if top 2 form 'AB' or 'CD'. Resulting length = stack size.
2696. Minimum String Length After Removing Substrings Difficulty: Easy Topics: String, Stack, Simulation 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. Example 1: Input: s = "ABFCACDB" Output: 2 Explanation: We can do the following operati...
