[C++] Greedy (One-Pass)
Intuition\n Describe your first thoughts on how to solve this problem. \n- Assume there are 3 characters word[i - 1], word[i], word[i + 1], and they are adjacen
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Assume there are 3 characters `word[i - 1]`, `word[i]`, `word[i + 1]`, and they are adjacent\n- We can always find a character `x` such that `word[i - 1]`, `x`, `word[i + 1]` are not adjacent to each other\n- Brief Prove\n  - For `word[i - 1]`, `3` characters are adjacent to it\n  - For `word[i + 1]`, `3` characters are adjacent to it\n  - So there are at least `26 - 3 - 3 = 20` characters that are not adjacent to `word[i - 1]` nor `word[i + 1]`\n  - That is, there are at lease `20` characters that can replace the `word[i]`\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Start from `word[1]`\n- If `word[i - 1]` and `word[i]` are adjacent\n  - increase the result `op`\n  - move to `word[i + 2]`, because `word[i + 1]` is not adjacent after replacing the `word[i]`\n# Complexity\n- Time complexity: $$O(n)$$\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```\nclass Solution {\npublic:\n    // time/space: O(n)/O(1)\n    int removeAlmostEqualCharacters(string word) {\n        int n = word.size();\n        int op = 0;\n        for (int i = 1; i < n; i++) {\n            if (abs(word[i - 1] - word[i]) <= 1) op++, i++;\n        }\n        return op;\n    }\n};\n```
['Greedy', 'C++']