Back to problems

Eliminate Adjacent Duplicate Characters

Algorithm · Oracle · Medium

Problem Statement You are given a string str of length L that contains only lowercase letters. In a single operation, you can pick any index and change its character to any other lowercase letter. Your task is to compute the minimum number of such operations required so that the resulting string has no two adjacent characters that are equal. Constraints 1 ≤ L ≤ 10^5 str consists exclusively of lowercase English letters ('a' – 'z'). Examples Example 1 Input: str = "caaab"…

Checking your access…