TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 3379,3 "name": "score_of_a_string",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/score-of-a-string/",6 "date": "2024-03-30 00:00:00",7 "task_description": "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`. **Example 1:** **Input:** s = \"hello\" **Output:** 13 **Explanation:** The **ASCII** values of the characters in `s` are: `'h' = 104`, `'e' = 101`, `'l' = 108`, `'o' = 111`. So, the score of `s` would be `|104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| = 3 + 7 + 0 + 3 = 13`. **Example 2:** **Input:** s = \"zaz\" **Output:** 50 **Explanation:** The **ASCII** values of the characters in `s` are: `'z' = 122`, `'a' = 97`. So, the score of `s` would be `|122 - 97| + |97 - 122| = 25 + 25 = 50`. **Constraints:** `2 <= s.length <= 100` `s` consists only of lowercase English letters.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"hello\"",12 "output": "13 "13 },14 {15 "label": "Example 2",16 "input": "s = \"zaz\"",17 "output": "50 "18 }19 ],20 "private_test_cases": [21 {22 "input": "ggmnxugmzbgeuowbrszedcmslic",23 "output": 21424 },25 {26 "input": "wwd",27 "output": 1928 },29 {30 "input": "ixqhyzqwfcraprwdtoijaapsjhtdahmeuizvcxcfmnmjycthgiwcetjavtkaziffkpgivsuwujrjd",31 "output": 70132 },33 {34 "input": "mwlzgfibhouglxsgmuebmwazdxokswzwtbrjxrpwpccmxrcabffahzhujjmpcliarwwk",35 "output": 59436 },37 {38 "input": "xdilrjtgkglzjeg",39 "output": 11540 }41 ],42 "haskell_template": "scoreOfString :: String -> Int\nscoreOfString s ",43 "ocaml_template": "let scoreOfString (s: string) : int = ",44 "scala_template": "def scoreOfString(s: String): Int = { \n \n}",45 "java_template": "class Solution {\n public int scoreOfString(String s) {\n \n }\n}",46 "python_template": "class Solution(object):\n def scoreOfString(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "47}