#3498
Reverse Degree of a String
easy · 88.6% accepted · 84 likes · top 99%
Description
Given a string s, calculate its reverse degree.
The reverse degree is calculated as follows:
- For each character, multiply its position in the reversed alphabet ('a' = 26, 'b' = 25, ..., 'z' = 1) with its position in the string (1-indexed).
- Sum these products for all characters in the string.
Return the reverse degree of s.
Solution