File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
main/java/io/github/spannm/leetcode/lc3/lc3100
test/java/io/github/spannm/leetcode/lc3/lc3100 Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ package io .github .spannm .leetcode .lc3 .lc3100 ;
2
+
3
+ import io .github .spannm .leetcode .LeetcodeProblem ;
4
+
5
+ import java .util .stream .IntStream ;
6
+
7
+ /**
8
+ * 3110. Score of a String.
9
+ */
10
+ class Problem3110 extends LeetcodeProblem {
11
+
12
+ int scoreOfString (String _s ) {
13
+ return IntStream .range (1 , _s .length ()).map (i -> Math .abs (_s .charAt (i - 1 ) - _s .charAt (i ))).sum ();
14
+ }
15
+
16
+ }
Original file line number Diff line number Diff line change
1
+ package io .github .spannm .leetcode .lc3 .lc3100 ;
2
+
3
+ import io .github .spannm .leetcode .LeetcodeBaseTest ;
4
+ import org .junit .jupiter .params .ParameterizedTest ;
5
+ import org .junit .jupiter .params .provider .CsvSource ;
6
+
7
+ class Problem3110Test extends LeetcodeBaseTest {
8
+
9
+ @ ParameterizedTest (name = "[{index}] {0} --> {1}" )
10
+ @ CsvSource (delimiter = ';' , value = {
11
+ "hello; 13" ,
12
+ "zaz; 50"
13
+ })
14
+ void test (String _s , int _expectedResult ) {
15
+ assertEquals (_expectedResult , new Problem3110 ().scoreOfString (_s ));
16
+ }
17
+
18
+ }
You can’t perform that action at this time.
0 commit comments