benchmarks.wiki / Public workspace

LiveCodeBench / 2800 / minimum-string-length-after-removing-substrings

Problem

Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.

contest date

2023-05-21T00:00:00

contest id

weekly-contest-346

difficulty

easy

platform

leetcode

question content

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 operations:
- Remove the substring "ABFCACDB", so s = "FCACDB".
- Remove the substring "FCACDB", so s = "FCAB".
- Remove the substring "FCAB", so s = "FC".
So the resulting length of the string is 2.
It can be shown that it is the minimum length that we can obtain.
Example 2:

Input: s = "ACBBD"
Output: 5
Explanation: We cannot do any operations on the string so the length remains the same.

 
Constraints:

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

question title

minimum-string-length-after-removing-substrings

starter code

Code

class Solution:
    def minLength(self, s: str) -> int:
        

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See how this is scored Scored by the benchmark’s own harness

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import