Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d4680f

Browse files
Solved 3110
1 parent 6dfa5b1 commit 7d4680f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package leetcode.editor.en;
2+
3+
import java.util.*;
4+
5+
class ScoreOfAString {
6+
7+
//leetcode submit region begin(Prohibit modification and deletion)
8+
class Solution {
9+
public int scoreOfString(String s) {
10+
int out = 0;
11+
for (int i = 1; i < s.length(); i++) {
12+
out += Math.abs(s.charAt(i - 1) - s.charAt(i));
13+
}
14+
return out;
15+
}
16+
}
17+
//leetcode submit region end(Prohibit modification and deletion)
18+
19+
20+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /