You are given a string `s`. The score of a string is the sum of the absolute differences between the ASCII values of every pair of adjacent characters. Return the score of `s`.
You are given a string s. The score of a string is the sum of the absolute differences between the ASCII values of every pair of adjacent characters. Return the score of s.
Example 1:
Input: {"s":"hello"}
Output: 13
Constraints:
2≤s.length≤100
s consists only of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"hello"}
Place every letter of "hello" on the a..z ruler. The score is the total distance travelled hopping from each letter to the next.
s, pair (i-1, i)
h
0
e
1
l
2
l
3
o
4
hops on the a..z ruler (distance = ASCII difference)