content: import com.sun.javafx.scene.NodeEventDispatcher;
  
  import java.awt.geom.CubicCurve2D;
  import java.security.PrivateKey;
  import java.util.HashMap;
  import java.util.Objects;
  
  /**
   * @author jzy
   * @GitHub <a href="https://github.com/567jin">567jin</a>
   * @since 2024-03-13 8:52:35
   */
  public class _138_CopyRandomList {
      public static void main(String[] args) {
  
      }
  
      public Node copyRandomList(Node head) {
          if (head == null) {
              return null;
          }
          HashMap<Node, Node> map = new HashMap<>();
          Node cur = head;
          while (cur != null) {
              map.put(cur, new Node(cur.val));  // 将当前节点和新节点绑定在一起
              cur = cur.next;
          }
          cur = head;
          while (cur != null) {
              map.get(cur).next = map.get(cur.next);
              map.get(cur).random = map.get(cur.random);
              cur = cur.next;
          }
          return map.get(head);
      }
  
      class Node {
          int val;
          Node next;
          Node random;
  
          public Node(int val) {
              this.val = val;
              this.next = null;
              this.random = null;
          }
      }
  }
  
  
  