Back to problems

Minimum Replacements for Adjacent Duplicate Characters

Algorithm · IBM · Medium

You are given an array of lowercase-only strings words. You are allowed to perform an operation on any word: pick one character and replace it with any other lowercase English letter. After some number of operations, a word is considered valid when no two adjacent characters are the same. For every word in the input, compute the smallest possible number of operations that will turn the word into a valid state. Return an integer array result of length words.length, where…

Checking your access…