原文链接: https://leetcode-cn.com/problems/add-two-numbers 英文原文You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers a…
标签详情
链表 分类
原文链接: https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list 英文原文Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: In…
原文链接: https://leetcode-cn.com/problems/merge-two-sorted-lists 英文原文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 li…
原文链接: https://leetcode-cn.com/problems/merge-k-sorted-lists 英文原文You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lis…
原文链接: https://leetcode-cn.com/problems/swap-nodes-in-pairs 英文原文Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be cha…
原文链接: https://leetcode-cn.com/problems/reverse-nodes-in-k-group 英文原文Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. …
原文链接: https://leetcode-cn.com/problems/rotate-list 英文原文Given the head of a linked list, rotate the list to the right by k places. Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2: Input: head = [0,1,2], k = 4 Output: [2,0,1] …
原文链接: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii 英文原文Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted…
原文链接: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list 英文原文Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 1: Input: head = [1,1…
原文链接: https://leetcode-cn.com/problems/partition-list 英文原文Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the…
原文链接: https://leetcode-cn.com/problems/convert-sorted-list-to-binary-search-tree 英文原文Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary …
原文链接: https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list 英文原文Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the nex…
原文链接: https://leetcode-cn.com/problems/copy-list-with-random-pointer 英文原文A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. Construct a deep copy of the li…
原文链接: https://leetcode-cn.com/problems/linked-list-cycle 英文原文Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by conti…
原文链接: https://leetcode-cn.com/problems/linked-list-cycle-ii 英文原文Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can b…
原文链接: https://leetcode-cn.com/problems/reorder-list 英文原文You are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form: L0 → Ln &r…
原文链接: https://leetcode-cn.com/problems/lru-cache 英文原文Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity.…
原文链接: https://leetcode-cn.com/problems/insertion-sort-list 英文原文Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorithm: Insertion sort iterates, consumin…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-linked-lists 英文原文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…
原文链接: https://leetcode-cn.com/problems/reverse-linked-list 英文原文Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list 英文原文Given the head of a singly linked list, return true if it is a palindrome. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The…
原文链接: https://leetcode-cn.com/problems/delete-node-in-a-linked-list 英文原文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 direct…
原文链接: https://leetcode-cn.com/problems/odd-even-linked-list 英文原文Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered…
原文链接: https://leetcode-cn.com/problems/design-twitter 英文原文Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed. Implement the Twitter cl…
原文链接: https://leetcode-cn.com/problems/linked-list-random-node 英文原文Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Implement the Solution class: Solution(ListNod…
原文链接: https://leetcode-cn.com/problems/all-oone-data-structure 英文原文Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts. Implement the AllOne class: AllOne() Initializes the object…
原文链接: https://leetcode-cn.com/problems/add-two-numbers-ii 英文原文You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers…
原文链接: https://leetcode-cn.com/problems/lfu-cache 英文原文Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the object with the capacity of the data structure. i…
原文链接: https://leetcode-cn.com/problems/swapping-nodes-in-a-linked-list 英文原文You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node fro…
原文链接: https://leetcode-cn.com/problems/split-linked-list-in-parts 英文原文Given the head of a singly linked list and an integer k, split the linked list into k consecutive linked list parts. The length of each part should be as equal as possible: no two …
1 / 3