c and d, or k and k).
You get a string text. One change puts any lowercase letter at any position. Find the smallest number of changes after which no two adjacent letters of the string are similar.text="moon" → 1
The trouble spots are "oo" and "on" (n and o are alphabet neighbours). Replacing the second o, e.g. "moxn", fixes both, so one change is enough.
text="bbbb" → 2
For example "bxbx": two changes, and fewer is impossible since pairs (0,1) and (2,3) do not overlap.
text="aceg" → 0
Neighbouring letters are already far apart, nothing to change.
text consists of lowercase English letterstext="moon"
1
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.