As reported: Salesforce full-stack software engineer online assessment (2025), question 2 of 2. Also asked in a 2025 Salesforce MTS online assessment.
For every word in words, find the minimum number of characters to replace (each with any lowercase letter) so that no two adjacent characters of the word are equal. Return the answers in order.
Example
words = ["add","boook","break","aaaaa"]
Output: [1,1,0,2]
"add" → "adc"; "boook" → "boxok"; "aaaaa" → "abaca".
Constraints: 1 ≤ words.length ≤ 100; 1 ≤ words[i].length ≤ 10^5; lowercase English letters.
Code runner format: one line: words as a JSON array. Implement minimalOperations(words); the harness prints the answers.