{ "id": 2800, "name": "minimum_string_length_after_removing_substrings", "difficulty": "Easy", "link": "https://leetcode.com/problems/minimum-string-length-after-removing-substrings/", "date": "2023-05-14 00:00:00", "task_description": "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.", "public_test_cases": [ { "label": "Example 1", "input": "s = \"ABFCACDB\"", "output": "2 " }, { "label": "Example 2", "input": "s = \"ACBBD\"", "output": "5 " } ], "private_test_cases": [ { "input": "YSWYFTJKQAOKKIFMPECDWLTTTHNBBDXVZKWPZPKMSDLMASHPDTCLYGNNWRIHOIYTZPAWMJZQ", "output": 70 }, { "input": "YNYISVNQYVTPTEGMRDVKYLQMFOTF", "output": 28 }, { "input": "ZQZTAMHNTPWIHNIWALGXQKILOOQXJGZVQBUNRYWSLNQTVVJOFAYOIJBXPKCDKZPSBXRZTCFFWSOZPOADZJCYJ", "output": 83 }, { "input": "RPSVIXXDMLSOMCXININPUSOZZATOGQRBWECXXQSTKZUZNHKIZWIVDPGGFGXNYQPMCZLMEWNY", "output": 72 }, { "input": "LJRZBTBNLKLPZ", "output": 13 }, { "input": "HTJYGETJMHWVAJHLFDOMPSOURF", "output": 26 }, { "input": "PWHXGCJLEAIQEHLAMEOZKELDCSLPTWRJYYSVFKWSUZIUPCHEUGVBFEFNVM", "output": 58 }, { "input": "NLPLSPPPYTCEOSTQZZUZNCVKAKJBBQMISVEZQIHRJKZSVAJXICLWMMF", "output": 55 }, { "input": "FFUDSNTHDPVWXHLQNRRXNQZMDOEPCMCMEZICPGUDBGKMZNZGSKCOPTKEAXLSQNWGYOMAXUKCSZG", "output": 75 }, { "input": "CRNGZMVRMIYXLBGLIKJEBZAVMXDGCXFGVAYUASJGNLMVCSV", "output": 47 } ], "haskell_template": "minLength :: String -> Int\nminLength s ", "ocaml_template": "let minLength (s: string) : int = ", "scala_template": "def minLength(s: String): Int = { \n \n}", "java_template": "class Solution {\n public int minLength(String s) {\n \n }\n}", "python_template": "class Solution(object):\n def minLength(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n " }