Easy C++ Solution
Video Explanation\nhttps://youtu.be/PgW73G4Um8I?si=E311v3I4mf52lNE9\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe task is to c
# Video Explanation\nhttps://youtu.be/PgW73G4Um8I?si=E311v3I4mf52lNE9\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe task is to compute the "score" of a given string based on the absolute differences between the ASCII values of consecutive characters. The idea is to measure how different each character is from the next in terms of their ASCII values and sum these differences to get the final score.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize a variable sum to store the cumulative score.\n2. Loop through the string from the first character to the second-to-last character.\n3. For each character at position i, calculate the absolute difference between the ASCII values of the character at i and i+1.\n4. Add this difference to sum.\n5. After the loop ends, return sum as the score of the string.\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int scoreOfString(string s) {\n        int sum=0;\n        for(int i=0;i<s.size()-1;i++){\n            sum+=abs(s[i]-s[i+1]);\n        }\n        return sum;\n    }\n};\n```
['C++']