Problem · String
Maximum String Operations
Learn this problemProblem statement
Choose three consecutive characters whose first two are equal and whose third differs, then replace the third with the repeated character. Apply the operation any number of times and return the maximum possible operation count.
Function
getMaximumOperations(s: String) → longExamples
Example 1
s = "accept"return = 3The pair cc can successively absorb e, p, and t.
Example 2
s = "aabaab"return = 2Two differing characters can be changed by the available repeated-a pairs.
Constraints
3 <= s.length <= 200000scontains lowercase English letters.