Question: 1 . String ModificationAs an aignment, students at HackerLand High School have been asked to modify a string by performing specific moves on it .
String ModificationAs an aignment, students at HackerLand High School have been asked to modify a string by performing specific moves on it Given a string sof lowercase English characters a two types of moves can be performed on any index, any number of times: Decrement the character by The letter a'cannot be decremented Increment the character by Letter cannot be incremented.For example, increment Pto g'or decrement Pto leThe string should be modified such that every character has at least equal adjacent character. The first and last characters of a string only have a single adjacent character, so the two characters at each end must match one another. For example, "aaabb" and"aacodd" are good, but "abaaa" and "abcdef are not.Calculate the minimum number of moves required to modify the string to a good form.ExampleacaDecrement C twice to get 'aaa'. A minimum of moves is required.Function DescriptionComplete the function getMinMoves in the editor below.getMinMoves has the following parameters:strings the stringReturnsint: the minimum moves required
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
