File tree 1 file changed +10
-10
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 13
13
14
14
public class _138 {
15
15
public static class Solution1 {
16
- public RandomListNode copyRandomList (RandomListNode head ) {
16
+ public Node copyRandomList (Node head ) {
17
17
/**Key is the original nodes, value is the new nodes we're deep copying to.*/
18
- Map <RandomListNode , RandomListNode > map = new HashMap ();
19
- RandomListNode node = head ;
18
+ Map <Node , Node > map = new HashMap ();
19
+ Node node = head ;
20
20
21
21
//loop for the first time: copy the node themselves with only labels
22
22
while (node != null ) {
23
- map .put (node , new RandomListNode (node .label ));
23
+ map .put (node , new Node (node .val ));
24
24
node = node .next ;
25
25
}
26
26
@@ -36,14 +36,14 @@ public RandomListNode copyRandomList(RandomListNode head) {
36
36
}
37
37
38
38
// Definition for singly-linked list with a random pointer.
39
- class RandomListNode {
40
- int label ;
39
+ class Node {
40
+ int val ;
41
41
42
- RandomListNode next ;
43
- RandomListNode random ;
42
+ Node next ;
43
+ Node random ;
44
44
45
- RandomListNode (int x ) {
46
- this .label = x ;
45
+ Node (int x ) {
46
+ this .val = x ;
47
47
}
48
48
}
49
49
}
You can’t perform that action at this time.
0 commit comments