Problem · String
Minimal Operations
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 i is the minimum substitutions for words[i]
: 𓏲🐋 ๋࣭ ࣪Credit to BananaInc˖✩࿐࿔ 🌊
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].
Example 2
words = ["ab", "aab", "abb", "abab", "abaaaba"]return = [0, 1, 1, 0, 1]Unknown for now. Will add once find the reference :)
Constraints
More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026