Question: 1 . String ModificationAs an aignment, students at HackerLand High School have been asked to modify a string by performing specific moves on it .

1. 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'-2), two types of moves can be performed on any index, any number of times:1. Decrement the character by 1. The letter a'cannot be decremented.2. Increment the character by 1. Letter 2' cannot be incremented.For example, increment Pto g'or decrement Pto leThe string should be modified such that every character has at least 1 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.Example5=*aca"Decrement 'C' twice to get 'aaa'. A minimum of 2 moves is required.Function DescriptionComplete the function getMinMoves in the editor below.getMinMoves has the following parameter(s):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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!