Description
Solutions
Minimal Operations
🔥 FULLTIME

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.

Function Description

Complete the function minimalOperations in the editor below.

minimalOperations has the following parameter(s):

  1. string words[n]: an array of strings

Returns

int[n]: each element i is the minimum substitutions for words[i]

: 𓏲🐋 ๋࣭  ࣪Credit to BananaInc˖✩࿐࿔ 🌊

Example 1:

Input:  words = ["add", "boook", "break"]
Output: [1, 1, 0]
Explanation:
1. 'add': change one d (1 change) 2. 'boook': change the middle o (1 change) 3. 'break': no changes are necessary (0 changes) The return array is [1, 1, 0].

Example 2:

Input:  words = ["ab", "aab", "abb", "abab", "abaaaba"]
Output: [0, 1, 1, 0, 1]
Explanation:
Unknown for now. Will add once find the reference :)
Constraints:
  • 1 ≤ n ≤ 100
  • 2 ≤ length of words[i] ≤ 105
  • Each character of words[i] is in the range ascii[a-z]
Thumbnail 0
Testcase

Result
Case 1

input:

output: