FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 3230,3 "name": "remove_adjacent_almost_equal_characters",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/remove-adjacent-almost-equal-characters/",6 "date": "2023-11-25 00:00:00",7 "task_description": "You are given a **0-indexed** string `word`. In one operation, you can pick any index `i` of `word` and change `word[i]` to any lowercase English letter. Return _the **minimum** number of operations needed to remove all adjacent **almost-equal** characters from_ `word`. Two characters `a` and `b` are **almost-equal** if `a == b` or `a` and `b` are adjacent in the alphabet. **Example 1:** ``` **Input:** word = \"aaaaa\" **Output:** 2 **Explanation:** We can change word into \"a**c**a**c**a\" which does not have any adjacent almost-equal characters. It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2. ``` **Example 2:** ``` **Input:** word = \"abddez\" **Output:** 2 **Explanation:** We can change word into \"**y**bd**o**ez\" which does not have any adjacent almost-equal characters. It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2. ``` **Example 3:** ``` **Input:** word = \"zyxyxyz\" **Output:** 3 **Explanation:** We can change word into \"z**a**x**a**x**a**z\" which does not have any adjacent almost-equal characters. It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3. ``` **Constraints:** `1 <= word.length <= 100` `word` consists only of lowercase English letters.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "word = \"aaaaa\"",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "word = \"abddez\"",17 "output": "2 "18 },19 {20 "label": "Example 3",21 "input": "word = \"zyxyxyz\"",22 "output": "3 "23 }24 ],25 "private_test_cases": [26 {27 "input": "egemspqbudprialxwsqfsbfebuuelyvzymevldlviaesalwhpaepxgxsspnmogegnozjintuq",28 "output": 1029 },30 {31 "input": "pgp",32 "output": 033 },34 {35 "input": "nyblzqabcwjcyuzezzlzxshqqpecfekiugft",36 "output": 537 },38 {39 "input": "omnbzkruaz",40 "output": 141 },42 {43 "input": "mbrfpgvglbadahkokomrsydnbvoueolbawkteoxpxvaxdxgudiuvtlqgisiiptatjdkcsdsfntgvgq",44 "output": 545 }46 ],47 "haskell_template": "removeAlmostEqualCharacters :: String -> Int\nremoveAlmostEqualCharacters word ",48 "ocaml_template": "let removeAlmostEqualCharacters (word: string) : int = ",49 "scala_template": "def removeAlmostEqualCharacters(word: String): Int = { \n \n}",50 "java_template": "class Solution {\n public int removeAlmostEqualCharacters(String word) {\n \n }\n}",51 "python_template": "class Solution(object):\n def removeAlmostEqualCharacters(self, word):\n \"\"\"\n :type word: str\n :rtype: int\n \"\"\"\n "52}