原文链接: https://leetcode-cn.com/problems/flatten-a-multilevel-doubly-linked-list 英文原文You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional child pointer. This child pointer may or may n…
标签详情
链表 分类
原文链接: https://leetcode-cn.com/problems/design-hashset 英文原文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 …
原文链接: https://leetcode-cn.com/problems/design-hashmap 英文原文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 (k…
原文链接: https://leetcode-cn.com/problems/linked-list-components 英文原文You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values. Return the number of connected components…
原文链接: https://leetcode-cn.com/problems/design-linked-list 英文原文Design your implementation of the linked list. You can choose to use a singly or doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the val…
原文链接: https://leetcode-cn.com/problems/design-circular-queue 英文原文Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and th…
原文链接: https://leetcode-cn.com/problems/middle-of-the-linked-list 英文原文Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Example 1: Input: head = [1,2,3,4,5]…
原文链接: https://leetcode-cn.com/problems/next-greater-node-in-linked-list 英文原文You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first …
原文链接: https://leetcode-cn.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list 英文原文Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return…
原文链接: https://leetcode-cn.com/problems/design-skiplist 英文原文Design a Skiplist without using any built-in libraries. A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing with treap and red-black tree which has th…
原文链接: https://leetcode-cn.com/problems/convert-binary-number-in-a-linked-list-to-integer 英文原文Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary re…
原文链接: https://leetcode-cn.com/problems/linked-list-in-binary-tree 英文原文Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path c…
原文链接: https://leetcode-cn.com/problems/design-browser-history 英文原文You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Imp…
原文链接: https://leetcode-cn.com/problems/merge-in-between-linked-lists 英文原文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. The blue edg…
原文链接: https://leetcode-cn.com/problems/design-front-middle-back-queue 英文原文Design a queue that supports push and pop operations in the front, middle, and back. Implement the FrontMiddleBack class: FrontMiddleBack() Initializes the queue. void pushFron…
原文链接: https://leetcode-cn.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points 英文原文A critical point in a linked list is defined as either a local maxima or a local minima. A node is a local maxima if the current node has …
原文链接: https://leetcode-cn.com/problems/reverse-nodes-in-even-length-groups 英文原文You are given the head of a linked list. The nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers …
原文链接: https://leetcode-cn.com/problems/remove-duplicate-node-lcci 英文原文Write code to remove duplicates from an unsorted linked list. Example1: Input: [1, 2, 3, 3, 2, 1] Output: [1, 2, 3] Example2: Input: [1, 1, 1, 1, 2] Output: [1, 2] Note: The length…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list-lcci 英文原文Implement a function to check if a linked list is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) t…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-linked-lists-lcci 英文原文Given two (singly) linked lists, determine if the two lists intersect. Return the inter­ secting node. Note that the intersection is defined based on reference, not …
原文链接: https://leetcode-cn.com/problems/list-of-depth-lcci 英文原文Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth D, you'll have D linked lists). Return a array cont…
原文链接: https://leetcode-cn.com/problems/linked-list-cycle-lcci 英文原文Given a circular linked list, implement an algorithm that returns the node at the beginning of the loop. Circular linked list: A (corrupt) linked list in which a node's next pointer po…
原文链接: https://leetcode-cn.com/problems/sum-lists-lcci 英文原文You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a …
原文链接: https://leetcode-cn.com/problems/stack-of-plates-lcci 英文原文Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshol…
原文链接: https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof 中文题目输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。 示例 1: 输入:head = [1,3,2] 输出:[2,3,1] 限制: 0 <= 链表长度 <= 10000 通过代码 高赞题解方法一:递归法解题思路: 利用递归: 先走至链表末端,回溯时依次将节点值加入列表 ,这样就可以实现链表值的倒序输出。 Python …
原文链接: https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof 中文题目输入两个递增排序的链表,合并这两个链表并使新链表中的节点仍然是递增排序的。 示例1: 输入:1->2->4, 1->3->4 输出:1->1->2->3->4->4 限制: 0 <= 链表长度 <= 1000 注意:本题与主站 21 题相同:https://leetcode-cn.com/problems/merge-two-s…
原文链接: https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof 中文题目输入一个链表,输出该链表中倒数第k个节点。为了符合大多数人的习惯,本题从1开始计数,即链表的尾节点是倒数第1个节点。 例如,一个链表有 6 个节点,从头节点开始,它们的值依次是 1、2、3、4、5、6。这个链表的倒数第 3 个节点是值为 4 的节点。 示例: 给定一个链表: 1->2->3->4->5, 和 k = 2. …
原文链接: https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof 中文题目定义一个函数,输入一个链表的头节点,反转该链表并输出反转后链表的头节点。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 限制: 0 <= 节点个数 <= 5000 注意:本题与主站 206 题相同:https://leetcode-cn.com/problems/reverse-linked-list/ …
原文链接: https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof 中文题目给定单向链表的头指针和一个要删除的节点的值,定义一个函数删除该节点。 返回删除后的链表的头节点。 注意:此题对比原题有改动 示例 1: 输入: head = [4,5,1,9], val = 5 输出: [4,1,9] 解释: 给定你链表中值为 5 的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -> 1 -> 9. 示例 2: …
原文链接: https://leetcode-cn.com/problems/fu-za-lian-biao-de-fu-zhi-lcof 中文题目请实现 copyRandomList 函数,复制一个复杂链表。在复杂链表中,每个节点除了有一个 next 指针指向下一个节点,还有一个 random 指针指向链表中的任意节点或者 null。 示例 1: 输入:head = [[7,null],[13,0],[11,4],[10,2],[1,0]] 输出:[[7,null],[13,0],[11,4]…