READ AT YOUR OWN RISK !!! || Simplified Approach || Beats 100 %🔥😊
IntuitionThe main thing to figure out here , how can i  make my a = 26 and so on ....ApproachWell first thing we can know is that i have to add 26 to my ans
mea
# Intuition
The main thing to figure out here , how can i  make my a = 26 and so on ....
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
Well first thing we can know is that i have to add 26 to my ans 
meaning  , you might be asking why ? well **let me Ask you how can you make a = 26**

u can't do stuff like "Ans = z - a - c - d - 5 - 26 + 100"
or start doing like 

int a = 26 ;
int b = 25 ;
int c = 24 ;

 et cetra lol 

```
Result += 26  ;
```
*now i also have to multiply that value with my index* so it's quite simple as stated in the question 
```
Result += (st + 1) * 26 ;
```
Why ? Add 1 in our Result because index starting index is 0
whereas i have to start multiplying with 1 so i hope you understand till now 


**How to Add a and other values now? from the string?**
Let's see I know i have to add 26 for 'a' so ho can i make that 0 when i get it in the string
```
Result += (st + 1) * (26 - (s[i] - 'a')) ;
lets check it in the simple way not the hard one :)

for : 
i = 0 ; // 'a'
Result += (0 + 1) * (26 - ('a' - 'a')) ; // = 26

what if i encounter b in the start or at any index then what ?
lets see that 
Result += (0 + 1) * (26 -  ('b' - 'a')) ;  // = 25
similarly for c = 24 and so till z = 1 
```

<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(N)
- Time complexity is O(N) as we havee to have to check for every value in the given string and add that value to our ans
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
- Since the their is only one variable we are using and that is our Result 
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```cpp []
class Solution {
public:
    int reverseDegree(string s) {
        int end =  s.length() - 1  ;
        int Result = 0  ;
        for(int i = 0 ; i <= end ; i += 1)
        {
             Result += (i + 1) * (26 - (s[i] - 'a')) ;
            // Damn Bro even a small bracket mistake makes the whole question go wrong lol
        }
        return Result ;
    }
};
```
['Math', 'C++']