DP (for fun)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int removeAlmostEqualCharacters(String word) {\n        int[] dp = new int[128];\n        for(int i = 0; i < word.length(); i++) {\n            char c = word.charAt(i);\n            int[] dp2 = new int[128];\n            for(char j = \'a\'; j <= \'z\'; j++) {\n                int min = word.length();\n                for(char k = \'a\'; k <= \'z\'; k++) {\n                    if(j - 1 <= k && k <= j + 1) continue;\n                    min = Math.min(min, dp[k]);\n                }\n                if(c != j) min++;\n                dp2[j] = min;\n            }\n            dp = dp2;\n        }\n        int res = word.length();\n        for(char a = \'a\'; a <= \'z\'; a++) {\n            res = Math.min(res, dp[a]);\n        }\n        return res;\n    }\n}\n```
['Java']