String Challenge (Generic)
At the TikTok Academy, students are learning how to improve video captions.
You are given a string caption that only has small Englsh letters ('a' to 'z'). You can make two kinds of changes to caption at any letter as many times as needed.
For example, you can change 'f' to 'e' (the letter before) or 'g' (the letter after).
What is your task this time? They want you to make that every letter in the caption has at least one same letter next to it. For example, "aaabb" and "aaccdd" are goooood, but "abaaa" and "abcdef" are veryyy bad 😭
Plz return the min num of changes needed to make the caption meets the rules mentioned above.
Thanks to Da Best Spike!⸜(。˃ ᵕ ˂ )⸝♡
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
2 <= |caption| <= 105