Java simple O(n) solution beats 100%
Simple idea is that if we see characters like almosteq1 almosteq2 almosteq3 pattern then we will pick almosteq2 to change, and resume from almosteq3. \n If we s
Simple idea is that if we see characters like `almosteq1 almosteq2 almosteq3` pattern then we will pick `almosteq2` to change, and resume from `almosteq3`. \n If we see characters like `almosteq1 almosteq2 notequalchar` pattern then we again need to change one character, but we can only jump one index i.e. change to`almosteq2`.\n\n```\nclass Solution {\n    public int removeAlmostEqualCharacters(String word) {\n        int tot = 0;\n        for (int i = 0; i+1 < word.length(); i++) {\n            if (isAlmostEqual(word.charAt(i), word.charAt(i+1))) {\n                if (i+2 < word.length() && isAlmostEqual(word.charAt(i+1), word.charAt(i+2))) {\n                    i++;\n                }\n                tot++;\n            }\n        }\n        return tot;\n    }\n   \n    boolean isAlmostEqual(char c1, char c2) {\n        return (c1 == c2) || (c1-c2 == 1) || (c2-c1 == 1);\n    }\n}\n```
[]