We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00704fb commit 5efbce1Copy full SHA for 5efbce1
Python/score-of-a-string.py
@@ -0,0 +1,11 @@
1
+# Time: O(n)
2
+# Space: O(1)
3
+
4
+# string
5
+class Solution(object):
6
+ def scoreOfString(self, s):
7
+ """
8
+ :type s: str
9
+ :rtype: int
10
11
+ return sum(abs(ord(s[i+1])-ord(s[i])) for i in xrange(len(s)-1))
0 commit comments