Skip to content

Commit 0e360df

Browse files
refactor 561
1 parent ea31c7b commit 0e360df

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/main/java/com/fishercoder/solutions/_561.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
All the integers in the array will be in the range of [-10000, 10000].*/
2525
public class _561 {
2626

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;
3235
}
33-
return sum;
3436
}
3537

3638
}

src/test/java/com/fishercoder/_561Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
* Created by fishercoder on 4/23/17.
1111
*/
1212
public class _561Test {
13-
private static _561 test;
13+
private static _561.Solution1 solution1;
1414
private static int expected;
1515
private static int actual;
1616
private static int[] nums;
1717

1818
@BeforeClass
1919
public static void setup() {
20-
test = new _561();
20+
solution1 = new _561.Solution1();
2121
}
2222

2323
@Test
2424
public void test1() {
2525
nums = new int[]{1, 4, 3, 2};
2626
expected = 4;
27-
actual = test.arrayPairSum(nums);
27+
actual = solution1.arrayPairSum(nums);
2828
assertEquals(expected, actual);
2929
}
3030

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy