Skip to content

Commit 011b393

Browse files
refactor 19
1 parent 21f4c0d commit 011b393

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* After removing the second node from the end, the linked list becomes 1->2->3->5.
1111
1212
Note:
13-
1413
Given n will always be valid.
1514
Try to do this in one pass.
1615
*/

src/test/java/com/fishercoder/_19Test.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
public class _19Test {
1212
private static _19.Solution1 solution1;
13+
private static _19.Solution3 solution3;
1314
private static ListNode head;
1415
private static ListNode expected;
1516

1617
@BeforeClass
1718
public static void setup() {
1819
solution1 = new _19.Solution1();
20+
solution3 = new _19.Solution3();
1921
}
2022

2123
@Test
@@ -25,4 +27,18 @@ public void test1() {
2527
assertEquals(expected, solution1.removeNthFromEnd(head, 2));
2628
}
2729

30+
@Test
31+
public void test2() {
32+
head = LinkedListUtils.contructLinkedList(new int[]{1, 2, 3, 4, 5});
33+
expected = LinkedListUtils.contructLinkedList(new int[]{1, 2, 3, 5});
34+
assertEquals(expected, solution3.removeNthFromEnd(head, 2));
35+
}
36+
37+
@Test
38+
public void test3() {
39+
head = LinkedListUtils.contructLinkedList(new int[]{1});
40+
expected = LinkedListUtils.contructLinkedList(new int[]{});
41+
assertEquals(expected, solution1.removeNthFromEnd(head, 1));
42+
}
43+
2844
}

0 commit comments

Comments
 (0)