Find the minimum operations to make a string beautiful.
Unlock detailed company stats for this questionUpgrade
A string is beautiful if no two adjacent characters are the same or adjacent in the alphabet. One operation changes any character to any lowercase letter. Return the minimum number of operations to make the string beautiful.
Function: int getMinimumOperationCount(string s). Example: 'bddje' -> 1 (change second d to f). 'a' and 'z' are not consecutive. Expected approach: DP over last letter, O(n * 26^2). Edge cases: length 1 -> 0; 'aa', 'ab', 'yx' must change; 'ac', 'az' are valid.
Format · Microsoft Data Science Intern OA (job 200041778).
Community answers
No answers contributed by the community yet.


