Trains the technique from
LeetCode 3110Score of a StringThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A strip strip holds lowercase letters. Its roughness is the total, taken over every pair of neighbouring letters, of how far apart the two sit in the alphabet.
Return the roughness.
Example 1
The two neighbouring pairs each sit one letter apart, so the roughness is 2.
Example 2
The two letters sit at opposite ends of the alphabet, twenty-five places apart.
Example 3
Every letter is the same, so no pair is any distance apart at all.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def score_of_string(strip: str) -> int:public int scoreOfString(String strip)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.