100% Beats || Simple CPP Solution || Anyone Will Understand
Intuition\nThe problem asks for finding the score of a string based on the absolute difference between consecutive characters in the string.\n\n# Approach\nTo s
# Intuition\nThe problem asks for finding the score of a string based on the absolute difference between consecutive characters in the string.\n\n# Approach\nTo solve this problem, we can iterate through the string and calculate the absolute difference between each character and its consecutive character. We\'ll accumulate these differences to get the final score of the string.\n\n# Complexity\nTime complexity: ( O(n) ), where ( n ) is the length of the string s. We iterate through the string once.\nSpace complexity: ( O(1) ). We use only a constant amount of extra space.\n\n# Code\n```\nclass Solution {\npublic:\n    int scoreOfString(string s) {\n        int count =0;\n        for(int i=0; i<s.size()-1;i++){\n            count = count+ abs(s[i]-s[i+1]);\n        }\n        return count;\n    }\n};\n```
['C++']