Skip to content

Commit 1e951de

Browse files
committed
备注
1 parent e86db91 commit 1e951de

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/main/java/com/chen/algorithm/study/test24/Solution2.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.chen.algorithm.study.test24;
22

3+
import org.junit.Test;
4+
35
/**
46
* 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
57
* <p>
@@ -27,7 +29,6 @@ public ListNode swapPairs(ListNode head) {
2729
ListNode firstNode = head;
2830
ListNode secondNode = head.next;
2931

30-
3132
firstNode.next = secondNode.next;
3233
secondNode.next = prev.next;
3334
prev.next = secondNode;
@@ -40,4 +41,22 @@ public ListNode swapPairs(ListNode head) {
4041
}
4142

4243

44+
@Test
45+
public void test(){
46+
ListNode l1_1 = new ListNode(1);
47+
ListNode l1_2 = new ListNode(2);
48+
ListNode l1_3 = new ListNode(3);
49+
ListNode l1_4 = new ListNode(4);
50+
51+
l1_1.next = l1_2;
52+
l1_2.next = l1_3;
53+
l1_3.next = l1_4;
54+
55+
ListNode result = swapPairs(l1_1);
56+
57+
System.out.println(result.val);
58+
System.out.println(result.next.val);
59+
System.out.println(result.next.next.val);
60+
System.out.println(result.next.next.next.val);
61+
}
4362
}

src/main/java/com/chen/algorithm/study/test83/Solution2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* @author : chen weijie
55
* @Date: 2019-09-08 02:19
6+
* @Description: zhunn 删除排序链表中的重复元素
67
*/
78
public class Solution2 {
89

0 commit comments

Comments
 (0)