O(n) | 0ms | beating 100%
IntuitionApproachComplexity
Time complexity:
O(n)
Space complexity:
O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```javascript []
/**
 * @param {string} word
 * @return {number}
 */
var removeAlmostEqualCharacters = function(word) {
    const len = word.length
    let result = 0


    for (let i = 1; i < len; ) {
        const code = word.charCodeAt(i), prev = word.charCodeAt(i - 1)
        const diff = Math.abs(code - prev)
        if (diff <= 1) {
            result++
            i += 2
        } else {
            i++
        }
    }


    return result
};
```
['JavaScript']