0ms - Beats 100% ✅🔥🔥🔥| Python, C++💻 | SUPER EASY Approach, Explanation📕
0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | SUPER EASY Approach, Explanation\uD83D\uDCD5\n\n## 1. Proof\n Describe yo
# 0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | SUPER EASY Approach, Explanation\uD83D\uDCD5\n\n## 1. Proof\n<!-- Describe your first thoughts on how to solve this problem. -->\n### 1.1. C++\n![image.png](https://assets.leetcode.com/users/images/f311fef7-e34a-4115-a27d-3e7f31d27297_1717225199.6368515.png)\n\n### 1.2. Python3\n![image.png](https://assets.leetcode.com/users/images/776fc50e-07df-4d7a-9f36-9d2a6f96a47c_1717225245.3333967.png)\n\n## 2. Algorithms\n* Simple traversing\n\n## 3. Code (with explanation each line)\n```python3 []\nclass Solution:\n    def scoreOfString(self, s: str) -> int:\n        res = 0 # Initialize result variable\n        for i in range(len(s) - 1): # We get i & i+1 at each index so we don\'t need to check i as the last index but i+1\n            res += abs(ord(s[i]) - ord(s[i + 1])) # `ord` to get the corresponding ASCII number of adjacent characters at i & i+1, subtract them and get the absolute value\n        return res # Return the final result\n```\n\n```cpp []\nclass Solution {\npublic:\n    int scoreOfString(string s) {\n        int res = 0;\n        for (int i=0; i < s.size() - 1; i++) {\n            res += abs(int(s[i]) - int(s[i + 1]));\n        }\n        return res;\n    }\n};\n```\n\n## 4. 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### Upvote if you find this solution helpful, thank you \uD83E\uDD0D
['String', 'Python', 'C++', 'Python3']