File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 24
24
All the integers in the array will be in the range of [-10000, 10000].*/
25
25
public class _561 {
26
26
27
- public int arrayPairSum (int [] nums ) {
28
- Arrays .sort (nums );
29
- int sum = 0 ;
30
- for (int i = 0 ; i < nums .length ; i += 2 ) {
31
- sum += nums [i ];
27
+ public static class Solution1 {
28
+ public int arrayPairSum (int [] nums ) {
29
+ Arrays .sort (nums );
30
+ int sum = 0 ;
31
+ for (int i = 0 ; i < nums .length ; i += 2 ) {
32
+ sum += nums [i ];
33
+ }
34
+ return sum ;
32
35
}
33
- return sum ;
34
36
}
35
37
36
38
}
Original file line number Diff line number Diff line change 10
10
* Created by fishercoder on 4/23/17.
11
11
*/
12
12
public class _561Test {
13
- private static _561 test ;
13
+ private static _561 . Solution1 solution1 ;
14
14
private static int expected ;
15
15
private static int actual ;
16
16
private static int [] nums ;
17
17
18
18
@ BeforeClass
19
19
public static void setup () {
20
- test = new _561 ();
20
+ solution1 = new _561 . Solution1 ();
21
21
}
22
22
23
23
@ Test
24
24
public void test1 () {
25
25
nums = new int []{1 , 4 , 3 , 2 };
26
26
expected = 4 ;
27
- actual = test .arrayPairSum (nums );
27
+ actual = solution1 .arrayPairSum (nums );
28
28
assertEquals (expected , actual );
29
29
}
30
30
You can’t perform that action at this time.
0 commit comments