The Remove Adjacent Almost-Equal Characters problem asks for the minimum number of operations to make no two adjacent characters "almost equal" (differ by at most 1 in ASCII value). In each operation, you change one character to any other. This medium coding problem uses greedy: skip characters when a violation is found (changing every other violating character minimizes operations). The string, greedy, and dynamic programming interview pattern is demonstrated.
Salesforce asks this to test greedy reasoning for minimum character changes. The key insight: when you find a violation at position i, change s[i] (or s[i+1]) and skip to i+2 to avoid re-processing already-resolved positions.
Greedy scan with skip. Scan left to right. When |s[i] - s[i-1]| <= 1 (almost equal adjacent pair): increment operation count, skip the next character (i+=2 effectively). Otherwise advance normally. The skip ensures you change s[i] to break the pair and don't re-examine it.
s="aaaa". Scan:
s="abcd": |a-b|=1, |b-c|=1, |c-d|=1. All almost-equal. Greedy: op at i=1 (skip i=2). op at i=3. Result = 2.
Adjacent-pair violation problems often have greedy solutions using "fix and skip." When a violation occurs at position i, fix it and skip the next position (since it can't conflict with the already-fixed position). This greedy achieves the minimum number of changes. Practice: "minimum deletions to avoid adjacent identical characters," "minimum flips to separate alternating bits."