Intuitive solution with array to map character to value in reversed alphabet
IntuitionWe'll use a simple array to map each lowercase character to its value in the reversed alphabet.ApproachWe'll set up a simple array to map each lowercas
# Intuition

We'll use a simple array to map each lowercase character to its value in the reversed alphabet.

# Approach

We'll set up a simple array to map each lowercase character to its value in the reversed alphabet:
```ts
const m = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
```

We then loop over over the string and map each character while multiplying it with the 1-indexed position in `s`:
```ts
let result = 0;
for (let i = 0; i < s.length; i++) {
  result += (i + 1) * m[s[i].charCodeAt(0) - 97];
}
```

# Complexity
- Time complexity: $$O(n)$$

- Space complexity: $$O(n)$$

# Code
```typescript []
function reverseDegree(s: string): number {

  const m = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];

  let result = 0;
  for (let i = 0; i < s.length; i++) {
    result += (i + 1) * m[s[i].charCodeAt(0) - 97];
  }
    
  return result;
};
```
['Array', 'String', 'TypeScript']