Minimum Adjacent Fixes
Preview mode. Log in to edit, run, submit, and save progress.
Easy
Minimum Adjacent Fixes
A text cleaner receives several words. For each word, it wants to remove every case where two neighboring characters are the same. In one operation, you may replace any character with any other character. For every word, return the minimum number of replacements needed so that no two adjacent characters are equal.
Examples
Example 1
Input:
3 add boook break
Output:
1 1 0
Explanation: In add, one of the two d characters can be changed. In boook, changing one o is enough. The word break already has no equal adjacent characters.
Approach hint
Equal adjacent characters form independent runs.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp