🔥 Very Easy Detailed Solution || 🎯 JAVA || 🎯 C++
Approach

The given function computes a "reverse degree" for a string, where each character's contribution is calculated based on its reverse position in the al
# Approach
<!-- Describe your approach to solving the problem. -->
1. The given function computes a "reverse degree" for a string, where each character's contribution is calculated based on its reverse position in the alphabet.

2. reversedValue = 26 - (s.charAt(i) - 'a'): This gives the reverse alphabetical position of a character ('a' becomes 26, 'b' becomes 25, ..., 'z' becomes 1).

3. The character's contribution to the final sum is weighted by its 1-based position in the string: sum += reversedValue * position.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$O(n)$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$O(1)$
# Code
```java []
class Solution {
    public int reverseDegree(String s) {
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            int reversedValue = 26 - (s.charAt(i) - 'a'); 
            int position = i + 1; 
            sum += reversedValue * position;
        }
        return sum;
    }
}
```
```C++ []
class Solution {
public:
    int reverseDegree(string s) {
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            int reversedValue = 26 - (s[i] - 'a'); 
            int position = i + 1;
            sum += reversedValue * position;
        }
        return sum;
    }
};
```
['Math', 'String', 'String Matching', 'Simulation', 'C++', 'Java']