Java O(1) solution very simple
\n---\n\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
\n---\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int removeAlmostEqualCharacters(String word) {\n        \n        int ans=0;\n        int n=word.length();\n        int i=1;\n\n        while(i<n) {\n            char c1=word.charAt(i);\n            char c2=word.charAt(i-1);\n\n            if(c1==c2 || Math.abs(c1-\'0\'+1)==Math.abs(c2-\'0\') || Math.abs(c1-\'0\')==Math.abs(c2-\'0\'+1)) {\n                ans++;\n                i+=2;\n            }else i++;\n        }\n        return ans;\n    }\n}\n\n\n```
['Java']