Node
-
Linked List | Merge In Between Linked ListsAlgorithm/Linked List 2021. 5. 13. 23:29
You are given two linked lists: list1 and list2 of sizes n and m respectively. Remove list1's nodes from the ath node to the bth node, and put list2 in their place. Medium 난이도의 문제이다. 두 Linked List가 주어졌을 때, list1의 a번부터 b를 삭제한 후, 삭제된 자리에 list2를 넣는 문제이다. O(N)으로 해결하기 위해 아래와 같이 접근했다. class Solution { public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) { ListNode temp = null; ..
-
Linked List | Delete Node in a Linked ListAlgorithm/Linked List 2021. 4. 28. 22:52
Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. Constraints: * The number of the nodes in the given list is in the range [2, 1000]. * -1000