-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution035Test.java
More file actions
35 lines (27 loc) · 909 Bytes
/
Solution035Test.java
File metadata and controls
35 lines (27 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.portgas;
import org.junit.Test;
import com.portgas.Solution035.RandomListNode;
public class Solution035Test {
@Test
public void test() {
// 1 -> 2 -> 3 -> 4
// |_________|
RandomListNode node1 = new RandomListNode(1);
RandomListNode node2 = new RandomListNode(2);
RandomListNode node3 = new RandomListNode(3);
RandomListNode node4 = new RandomListNode(4);
node1.next = node2;
node2.next = node3;
node2.random = node4;
node3.next = node4;
RandomListNode result1 = new Solution035().clone(node1);
while (result1 != null) {
System.out.print(result1.label);
if (result1.random != null) {
System.out.print("_random_" + result1.random.label);
}
System.out.print(",");
result1 = result1.next;
}
}
}