Skip to content

Practice Score of a String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3110
LeetCode Problem

Score of a String

Problem Statement

You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Return the score of s.

Source: Score of a String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "hello"
Output
13

# Example 2

Input
s = "zaz"
Output
50

Constraints

2 <= s.length <= 100
s consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Score of a String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.