Skip to content

Commit a6f75dc

Browse files
refactor 167
1 parent 66939c6 commit a6f75dc

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ public int[] twoSum(int[] numbers, int target) {
3232
} else if (sum < target) {
3333
left++;
3434
} else {
35-
int[] res = new int[2];
36-
res[0] = left + 1;
37-
res[1] = right + 1;
38-
return res;
35+
return new int[]{left + 1, right + 1};
3936
}
4037
}
41-
return new int[] {-1, -1};
38+
return new int[]{-1, -1};
4239
}
4340
}
4441
}

src/test/java/com/fishercoder/_167Test.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
import static org.junit.Assert.assertArrayEquals;
88

99
public class _167Test {
10-
private static _167.Solution1 solution1;
11-
private static int[] numbers;
12-
private static int[] expected;
10+
private static _167.Solution1 solution1;
11+
private static int[] numbers;
12+
private static int[] expected;
1313

14-
@BeforeClass
15-
public static void setup() {
16-
solution1 = new _167.Solution1();
17-
}
14+
@BeforeClass
15+
public static void setup() {
16+
solution1 = new _167.Solution1();
17+
}
1818

19-
@Test
20-
public void test1() {
21-
numbers = new int[] {-3, 3, 4, 90};
22-
expected = new int[] {1, 2};
23-
assertArrayEquals(expected, solution1.twoSum(numbers, 0));
24-
}
19+
@Test
20+
public void test1() {
21+
numbers = new int[]{-3, 3, 4, 90};
22+
expected = new int[]{1, 2};
23+
assertArrayEquals(expected, solution1.twoSum(numbers, 0));
24+
}
2525
}

0 commit comments

Comments
 (0)