|@Rahul Jadhav 1||466|
Ishaan is playing with strings these days. He has found a new string. He wants to modify it as per the following rules to make it valid:
Find the minimum number of characters which Ishaan must insert in the string to make it valid.
Input: S = aabbbcc Output: 1 Explanation: In aabbbcc 3 b's occur consecutively, we add a 'd',and Hence, output will be aabbdbcc.
Input: S = aaaaa Output: 2 Explanation: In aaaaa 5 a's occur consecutively,we need to add 2 'b', and Hence, the output will be aababaa.
This is a function problem. You only need to complete the function modified() that returns the answer.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
1 <= Length of S <= 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes