Compute the score of a string by summing the absolute differences of adjacent character codes.
Given a string s, define its score as the sum of the absolute differences between the ASCII values of every pair of adjacent characters.
For example, for s = "abc", the score is |a-b| + |b-c|.
Return the score of the string.
This is a straightforward character-by-character computation over the string.
s.s.Example 1
Input
s = "hello"
Output
13
Explanation
Adjacent differences are |'h'-'e'| = 3, |'e'-'l'| = 7, |'l'-'l'| = 0, and |'l'-'o'| = 3. The total is 13.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.