로딩
요청 처리 중입니다...

JAVA_LeetCode 138_Copy List with Random Pointer

 JAVA_LeetCode 138_Copy List with Random Pointer

JAVA_LeetCode 138_Copy List with Random Pointer 풀이 class Solution { public Node copyRandomList(Node head) { // map 키를 원본 노드, value를 복제 노드로 넣는다. if(head == null) return null; HashMap map = new HashMap(); // 모든 노드 복제 및 해시맵에 저장 Node curr = head; while(curr != null){ map.put(curr, new Node(curr.val)); curr = curr.next; } // 각 복제 노드의 next와 random 연결 설정 curr = head; while(curr !

= null){ Node copyNode = map.get(curr); copyNode.next = (curr.next != null) ?

map.get(curr.next) : null; copyNo...