
LinkedList
weixin_39145266
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
23 Merge k Sorted Lists
1 题目Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3-...原创 2019-12-01 15:06:16 · 95 阅读 · 0 评论 -
445 Add Two Numbers II
1 题目You are given twonon-emptylinked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and re...原创 2019-07-12 21:09:59 · 86 阅读 · 0 评论 -
328 Odd Even Linked List
1 题目Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do i...原创 2019-07-03 00:05:04 · 79 阅读 · 0 评论 -
234 Palindrome Linked List
1 题目Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) ...原创 2019-05-07 14:57:01 · 106 阅读 · 0 评论 -
206 Reverse Linked List
1 题目Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or re...原创 2019-04-26 15:54:21 · 86 阅读 · 0 评论 -
148 Sort List
1 题目Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: ...原创 2019-04-22 13:32:11 · 76 阅读 · 0 评论 -
147 Insertion Sort List
1 题目Sort a linked list using insertion sort.A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration on...原创 2019-04-22 12:49:12 · 118 阅读 · 0 评论 -
160 Intersection of Two Linked Lists
1 题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Inpu...原创 2019-04-26 11:42:17 · 116 阅读 · 0 评论 -
143 Reorder List
1 题目Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1-...原创 2019-04-22 11:46:33 · 87 阅读 · 0 评论 -
109 Convert Sorted List to Binary Search Tree
1 题目convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than ...原创 2019-04-17 11:26:42 · 93 阅读 · 0 评论 -
86 Partition List
1 题目Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in eac...原创 2019-03-29 09:16:55 · 85 阅读 · 0 评论 -
138 Copy List with Random Pointer
1 题目A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Example 1:Input:{"$...原创 2019-04-02 14:01:21 · 124 阅读 · 0 评论 -
82 Remove Duplicates from Sorted List II
1 题目Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output:...原创 2019-03-29 09:17:55 · 56 阅读 · 0 评论 -
24 Swap Nodes in Pairs
1 题目Given alinked list, swap every two adjacent nodes and return its head.You maynotmodify the values in the list's nodes, only nodes itself may be changed.2 尝试解/** * Definition for singl...原创 2019-03-29 09:18:04 · 67 阅读 · 0 评论 -
92 Reverse Linked List II
1 题目Reverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2-...原创 2019-03-30 11:28:00 · 88 阅读 · 0 评论 -
61 Rotate List
1 题目Given a linkedlist, rotate the list to the right bykplaces, wherekis non-negative.2 尝试解class Solution {public: ListNode* rotateRight(ListNode* head, int k) { if(head == NU...原创 2019-03-29 09:16:15 · 85 阅读 · 0 评论 -
142 Linked List Cycle II
1 题目Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.To represent a cycle in the given linked list, we use an integerposwhich represents the positio...原创 2019-03-29 15:21:34 · 76 阅读 · 0 评论