HTMLify

LootCode - Score of a String - Python
Views: 10 | Author: abh
class Solution:
    def scoreOfString(self, s: str) -> int:
        values = []
        for c in s:
            values.append(ord(c))
        score = 0
        for i in range(len(values)-1):
            score += abs(values[i] - values[i+1])
        return score

Comments