Skip to content

Commit b98eab3

Browse files
authored
Create 3498-reverse-degree-of-a-string.js
1 parent 20c3549 commit b98eab3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

3498-reverse-degree-of-a-string.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var reverseDegree = function(s) {
6+
return Array.from(s).reduce((sum, ch, i) => {
7+
const pos = 'z'.charCodeAt(0) - ch.charCodeAt(0) + 1
8+
return sum + pos * (i + 1)
9+
}, 0)
10+
};

0 commit comments

Comments
 (0)