Dashboard Temp Share Shortlinks Frames API

HTMLify

index.py
Views: 2 | Author: devwajahat
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class Solution(object):
    def scoreOfString(self, s):
        """
        :type s: str
        :rtype: int
        """
        
        score = 0

        for i in range(len(s) - 1):
            score += abs(ord(s[i]) - ord(s[i + 1]) )
        return score