C# Solution [Runtime 1 ms Beats 100.00% & Memory 41.86 MB Beats 90.52%]
IntuitionWe just have to use the hint, it said "Simulate the operations as described", which is useful.Normally, the problem is clear without a hint.
I just loo
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We just have to use the hint, it said "Simulate the operations as described", which is useful.

Normally, the problem is clear without a hint.
I just look in the hint hoping for 0 ms runtime tip, but there's nothing, I don't know what can I do to reach 0 ms.

But this solution I reach, it's time complexity O(n) with space complexity of O(1).

We have to iterate over all characters, and then we have to use the number 123 (why because z have to be one, while z have ascii code of 122, so 123 - 122 = 1 and a have ascci code of 97, so 123 - 97 = 26), so we don't need to use 'z' - s[i] + 1.
I optimize it by using iteration from 0 until s.Length, then we pre-increment i in the calculation of i (better than use i + 1 and increment i after that for the next iteration). 

# Approach
<!-- Describe your approach to solving the problem. -->
1. Initialize the result variable.
```
        int res = 0;
```
2. Loop over all characters and calculate the result.
```
        for(int i = 0; i < s.Length;){
            res += (123 - s[i]) * ++i;
        }
```
3. Return the result.
```
        return res;
```
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
![image.png](https://assets.leetcode.com/users/images/3d927574-e78d-4e6a-8fb4-2a6e307198ff_1744118114.4443429.png)
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
![image.png](https://assets.leetcode.com/users/images/6ee46f98-adf4-4c86-9765-ba372c4052c7_1744118125.9036689.png)

# Code
```csharp []
public class Solution {
    public int ReverseDegree(string s) {
        int res = 0;
        for(int i = 0; i < s.Length;){
            res += (123 - s[i]) * ++i;
        }
        return res;
    }
}
```
['Math', 'String', 'Simulation', 'C#']