Company: IBM
Difficulty: medium
Minimum Character Substitution For each word in a list of words, if any two adjacent characters are equal, change one of them. Determine the minimum number of substitutions so the final string contains no adjacent equal characters. vector<int> minimalOperations(vector<string> words) Example words = [\'add\', \'boook\', \'break\'] \'add\': change one d (1 change) \'boook\': change the middle o (1 change) \'break\': no changes are necessary (0 changes) The return array is [1,1,0]. Function Description Complete the function minimalOperations in the editor below. Parameters string words[n]: an array of strings Returns int[n]: each element i is the minimum substitutions for words[i] Constraints 1 ≤ n ≤ 100 2 ≤ length of words[i] ≤ 10 5 Each character of words[i] is in the range ascii[a-z] Sample Case 0 Sample Input 0 5 ab aab abb abab abaaba Sample Output 0 0 1 1 0 1 Explanation 0 words = \'ab\' is already acceptable, so 0 replacements are needed. words = \'aab\' Replace an \'a\