Google 태그 관리자 아이콘
반응형

전체 글 177

.leetcode(138. Copy List with Random Pointer)

https://leetcode.com/problems/copy-list-with-random-pointer/ 1. 2022/05/07 시도 소요시간: 21분( 공간복잡도 O(n)), 13분( 공간복잡도O(1)) // 공간복잡도 O(n) class Solution { public Node copyRandomList(Node head) { Map map = new HashMap(); Node dummyNode = new Node(0); Node dummyHead = dummyNode; Node current = head; while (current != null) { Node newNode = new Node(current.val); dummyNode.next = newNode; newNode.random ..

알고리즘 풀이 2022.05.07

.leetcode(708. Insert into a Sorted Circular Linked List)

https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list/ 1. 2022/05/07 시도 소요시간: 25분 class Solution { public Node insert(Node head, int insertVal) { if (head == null) { head = new Node(insertVal); head.next = head; return head; } Node prev = head; Node current = head; while (true) { current = current.next; if (current == head) { Node newNode = new Node(insertVal); prev.next = newN..

알고리즘 풀이 2022.05.07
반응형