'Algorithm/Linked List' 카테고리의 글 목록 'Algorithm/Linked List' 카테고리의 글 목록
본문 바로가기

Algorithm/Linked List9

[LeetCode] Intersection of Two Linked Lists in JavaScript Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null. For example, the following two linked lists begin to intersect at node c1: The test cases are generated such that there are no cycles anywhere in the entire linked structure. Note that the linked lists must retain their or.. 2022. 3. 11.
[LeetCode] Merge Two Sorted Lists in JavaScript You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = [0].. 2022. 3. 10.
[LeetCode] Design HashMap in JavaScript Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists in the map, update the corresponding value. int get(int key) returns the value to which the specified key is mapped, or -1 if this map contains no.. 2022. 3. 9.
[LeetCode] Design HashSet in JavaScript Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. bool contains(key) Returns whether the value key exists in the HashSet or not. void remove(key) Removes the value key in the HashSet. If key does not exist in the HashSet, do nothing. Example 1: Input ["MyHashSet", "add", "add", "contains", "contains".. 2022. 3. 8.
LIST