Linear Check
We can go over the characters in a single iteration (linear solution) and check if two consecutive characters are adjacent. We would always update the later one
We can go over the characters in a single iteration (`linear` solution) and check if two consecutive characters are adjacent. We would always update the later one, as there is no benefit or updating the earlier one. Assuming there are more characters in the string (e.g. idx `2`), and we are upadting the middle (idx `1`) one between any two (e.g. `0` and `2`). There is always a possibe update among the 26 possible values that we can chose (for idx `1`) that will be not adjacent with the 2 characters (at idx `0` and `2`). This means that if we find adjacent characers at index `0` and `1`, we can skip comparing the next pair (at index `1` and `2`).\n\n# Code\n```\nclass Solution {\nprivate:\nbool isAdjacent (char a, char b) {\n    return abs (a - b) < 2;\n}\n\npublic:\n    int removeAlmostEqualCharacters(string word) {\n        \n        int changeCount = 0;\n        \n        for (int idx = 0; idx < word.length() - 1; idx++) {\n            char first = word[idx];\n            char second = word[idx + 1];\n            \n            if (isAdjacent(first, second)) {\n                changeCount++;\n                idx++; // skip the next check. IF we have "xyz" we can modify "y" to avoid being adjacent with "z", too. No need to check the next position.\n            }\n        }\n\n        return changeCount;\n    }\n};\n```
['C++']