← 返回 ibm 的题目列表Minimum Deletions to Eliminate Adjacent Equal Characters
类型:online_judge
Given a string s, one operation deletes any single character from the string.
Return the minimum number of deletions required so that the resulting string contains no pair of equal adjacent characters.
Input Format
One line containing the string s.
Output Format
Print one integer: the minimum number of operations.
Example 1
Input:
aabbbacc
Output:
4
Explanation: Keep one character from each consecutive run. For example, the result can be abac.
Example 2
Input:
abcd
Output:
0
Constraints
1 <= len(s) <= 2 * 10^5
s may contain letters, digits, or other ordinary characters.
Example
Input
aabbbacc
Output
4