Problem · String
No Pairs Allowed
Learn this problemProblem statement
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
minimalOperations(words: String[]) → int[]
Complete the function minimalOperations in the editor below.
minimalOperations has the following parameter(s):
string words[n]: an array of strings
Returns
int[n]: each element is the minimum substitutions for words[i]
Examples
Example 1
words = ["add", "boook", "break"]return = [1, 1, 0]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].
Constraints
- 1 ≤ n ≤ 100
- 2 ≤ length of words[i] ≤ 10^5
- Each character of words[i] is in the range ascii[a-z].
More Akuna Capital problems
- Binary CircuitSeen Jul 2026
- Minimize Malware Spread by Removing a NodeOA · Seen Jul 2026
- Sort Array by FrequencyOA · Seen Jul 2026
- Array Challenge (QR Intern)OA · Seen Jul 2026
- Communications HandlerOA · Seen Jul 2026
- K Smallest SubstringOA · Seen Jul 2026
- Maximum K-Star SumOA · Seen Jul 2026
- Delivery Management SystemOA · Seen Jul 2026