Skip to content

Commit 8bc172c

Browse files
refactor 27
1 parent f0df015 commit 8bc172c

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
public class _27 {
44

5-
public static class Solution1 {
6-
public int removeElement(int[] nums, int val) {
7-
int i = 0;
8-
for (int j = 0; j < nums.length; j++) {
9-
if (nums[j] != val) {
10-
nums[i++] = nums[j];
5+
public static class Solution1 {
6+
public int removeElement(int[] nums, int val) {
7+
int i = 0;
8+
for (int j = 0; j < nums.length; j++) {
9+
if (nums[j] != val) {
10+
nums[i++] = nums[j];
11+
}
12+
}
13+
return i;
1114
}
12-
}
13-
return i;
1415
}
15-
}
1616
}

src/test/java/com/fishercoder/_27Test.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
import static junit.framework.TestCase.assertEquals;
99

1010
public class _27Test {
11-
private static _27.Solution1 solution1;
12-
private static int[] nums;
11+
private static _27.Solution1 solution1;
12+
private static int[] nums;
1313

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

19-
@Test
20-
public void test1() {
21-
nums = new int[] {3, 2, 2, 3};
22-
assertEquals(2, solution1.removeElement(nums, 3));
23-
}
19+
@Test
20+
public void test1() {
21+
nums = new int[]{3, 2, 2, 3};
22+
assertEquals(2, solution1.removeElement(nums, 3));
23+
}
2424

25-
@Test
26-
public void test2() {
27-
nums = new int[] {2, 2, 3};
28-
assertEquals(1, solution1.removeElement(nums, 2));
29-
}
25+
@Test
26+
public void test2() {
27+
nums = new int[]{2, 2, 3};
28+
assertEquals(1, solution1.removeElement(nums, 2));
29+
}
3030

31-
@Test
32-
public void test3() {
33-
nums = new int[] {1};
34-
assertEquals(0, solution1.removeElement(nums, 1));
35-
}
31+
@Test
32+
public void test3() {
33+
nums = new int[]{1};
34+
assertEquals(0, solution1.removeElement(nums, 1));
35+
}
3636
}

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