[Java / Python 3] Time O(n) space O(1) codes
\njava\n    public int scoreOfString(String s) {\n        int score = 0;\n        for (int i = 1; i < s.length(); ++i) {\n            score += Math.abs(s.charAt
\n```java\n    public int scoreOfString(String s) {\n        int score = 0;\n        for (int i = 1; i < s.length(); ++i) {\n            score += Math.abs(s.charAt(i) - s.charAt(i - 1));\n        }\n        return score;\n    }\n```\n```python\n    def scoreOfString(self, s: str) -> int:\n        return sum(abs(ord(x) - ord(y)) for x, y in pairwise(s))\n```\n
[]