Skip to main content
LeetCode 3110, Easy. Topics: String. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 26 parametrized pytest cases, and a playground notebook:

Problem

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.

Examples

Constraints

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

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026