3811. Reverse Degree of a String
My accepted Python solution to LeetCode problem 3811, Reverse Degree of a String, running in 9ms.
- Difficulty: Easy
- Python
- Runtime 9ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 9ms, memory 17.3MB, accepted 2025-12-30.
class Solution:
def reverseDegree(self, s: str) -> int:
return sum((26 - (ord(c) - ord('a'))) * (i + 1) for i, c in enumerate(s))