这题怎么做呀求助
7. TikTok String Challenge
At the TikTok Academy, students are learning how to improve video captions.
You are given a string caption that only has small English letters ('a' to 'z'). You can make two kinds of changes to the caption at any letter as many times as needed:
Change the letter to the one right before it in the alphabet. You cannot change 'a' because it's already the first letter.
Change the letter to the one right after it in the alphabet. You cannot change 'z' because it's already the last letter.
For example, you can change 'f' to 'e' (the letter before) or 'g' (the letter after).
Your task is to make sure that every letter in the caption has at least one same letter next to it. For example, "aaabb" and "aaccdd" are good captions, but "abaaa" and "abcdef" are not.
Return the minimum number of changes needed to make the caption meet this rule.
Example
caption = "aca"
You can change 'c' to 'b' (the letter before), then to 'a' (the letter before). Now the caption is 'aaa', which meets the rule.
In total, you need 2 changes to meet the rule, which is minimum possible.
_2_csoahelp%E5%9F%B9%E8%AE%AD%E4%B8%AD%E5%BF%83_%E6%9D%A5%E8%87%AA%E5%B0%8F%E7%BA%A2%E4%B9%A6%E7%BD%91%E9%A1%B5%E7%89%88.jpg)