Skip to content

Commit

Permalink
leetcode score of a string
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Apr 15, 2024
1 parent 363aa93 commit b694f5c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions leetcode/algorithms/easy/score_of_a_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Solution:
def scoreOfString(self, s: str) -> int:
c = 0
for i, e in enumerate(s):
if i == 0:
continue
c += abs(ord(s[i - 1]) - ord(e))
return c

0 comments on commit b694f5c

Please sign in to comment.