Algorithm · Salesforce · Medium
You are given a string s consisting of lowercase English letters. You may perform the following operation any number of times (including zero times): Choose an index i with 0 ≤ i ≤ n‑3 such that s[i] == s[i+1] and s[i+1] != s[i+2]. Replace s[i+2] with the value of s[i]. You can decide the order of operations to maximize the total count. Return the maximum number of operations that can be carried out on s. Example 1: Explanation: Perform the operation at i=1 (the three…
Checking your access…