Dashboard Temp Share Shortlinks Frames API

HTMLify

LootCode - Score of a String - Python
Views: 355 | Author: abh
1
2
3
4
5
6
7
8
9
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