![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
文章平均质量分 67
小榕流光
这个作者很懒,什么都没留下…
展开
-
[leetcode] 83. Remove Duplicates from Sorted List 解题报告
题目连接:https://leetcode.com/problems/remove-duplicates-from-sorted-list/Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, r原创 2015-12-27 16:10:19 · 392 阅读 · 0 评论 -
[leetcode] 86. Partition List 解题报告
题目链接:https://leetcode.com/problems/partition-list/Given 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 pres原创 2016-01-10 05:25:47 · 398 阅读 · 0 评论 -
[leetcode] 25. Reverse Nodes in k-Group 解题报告
题目链接:https://leetcode.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.If the number of nodes is not a m原创 2016-01-08 10:51:18 · 768 阅读 · 0 评论 -
[leetcode] 82. Remove Duplicates from Sorted List II 解题报告
题目链接:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original原创 2016-01-07 15:23:18 · 528 阅读 · 0 评论 -
[leetcode] 148. Sort List 解题报告
题目链接:https://leetcode.com/problems/sort-list/Sort a linked list in O(n log n) time using constant space complexity.思路:用快速排序的话一个比较难的问题是不能随机访问链表,而归并排序可以利用递归的性质。归并排序时间复杂度为O(n*log(n)),但是这题要求原创 2016-01-10 12:05:19 · 729 阅读 · 0 评论 -
[leetcode] 143. Reorder List 解题报告
题目链接:https://leetcode.com/problems/reorder-list/Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' va原创 2016-01-08 08:18:06 · 2375 阅读 · 0 评论 -
[leetcode] 142. Linked List Cycle II 解题报告
题目链接:https://leetcode.com/problems/linked-list-cycle-ii/Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.原创 2016-01-07 10:05:14 · 630 阅读 · 0 评论 -
[leetcode] 369. Plus One Linked List 解题报告
题目链接: https://leetcode.com/problems/plus-one-linked-list/Given a non-negative number represented as a singly linked list of digits, plus one to the number.The digits are stored such that the原创 2016-06-28 23:52:19 · 3285 阅读 · 0 评论 -
[leetcode] 2. Add Two Numbers 解题报告
题目链接:https://leetcode.com/problems/add-two-numbers/You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a原创 2016-01-08 09:12:21 · 473 阅读 · 0 评论 -
[leetcode] 23. Merge k Sorted Lists 解题报告
题目链接:https://leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:刚开始想要两两合并,但是超时了,后来看到用优先队列来做会降低很原创 2016-01-10 10:23:12 · 712 阅读 · 0 评论 -
[leetcode] 109. Convert Sorted List to Binary Search Tree 解题报告
题目链接:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:这题的思路原创 2016-01-10 16:02:39 · 575 阅读 · 0 评论 -
[leetcode] 362. Design Hit Counter 解题报告
题目链接: https://leetcode.com/problems/design-hit-counter/Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in sec原创 2016-06-24 14:40:31 · 3296 阅读 · 0 评论 -
[leetcode] 61. Rotate List 解题报告
题目链接:https://leetcode.com/problems/rotate-list/Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5原创 2016-01-08 06:55:50 · 400 阅读 · 0 评论 -
[leetcode] 92. Reverse Linked List II 解题报告
题目链接:https://leetcode.com/problems/reverse-linked-list-ii/Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,原创 2016-01-08 09:54:06 · 461 阅读 · 0 评论 -
[leetcode] 206. Reverse Linked List 解题报告
题目链接:https://leetcode.com/problems/reverse-linked-list/Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could原创 2016-01-07 11:17:33 · 505 阅读 · 0 评论 -
[leetcode] 203. Remove Linked List Elements 解题报告
题目链接:https://leetcode.com/problems/remove-linked-list-elements/Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, v原创 2016-01-07 13:53:23 · 415 阅读 · 0 评论 -
[leetcode] 147. Insertion Sort List 解题报告
题目链接:https://leetcode.com/problems/insertion-sort-list/Sort a linked list using insertion sort.思路:我发现自从用了虚拟头结点之后刷链表简直是毫无阻碍,哈哈!!代码如下:/** * Definition for singly-linked list. * struct Li原创 2016-01-07 15:48:06 · 471 阅读 · 0 评论 -
[leetcode] 141. Linked List Cycle 解题报告
题目链接:https://leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:用快慢指针,慢的一次走一步,快的一次走两原创 2016-01-07 15:55:45 · 376 阅读 · 0 评论 -
[leetcode] 24. Swap Nodes in Pairs 解题报告
题目链接:https://leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2-原创 2016-01-07 16:11:20 · 410 阅读 · 0 评论 -
[leetcode] 19. Remove Nth Node From End of List 解题报告
题目链接:https://leetcode.com/problems/remove-nth-node-from-end-of-list/Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2原创 2015-12-28 09:58:15 · 378 阅读 · 0 评论 -
[leetcode] 328. Odd Even Linked List 解题报告
题目链接:https://leetcode.com/problems/odd-even-linked-list/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原创 2016-02-20 00:14:03 · 598 阅读 · 0 评论 -
[leetcode] 237. Delete Node in a Linked List 解题报告
题目链接:https://leetcode.com/problems/delete-node-in-a-linked-list/Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linke原创 2015-12-27 15:14:32 · 416 阅读 · 0 评论 -
[leetcode] 21. Merge Two Sorted Lists 解题报告
题目链接:https://leetcode.com/problems/merge-two-sorted-lists/Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lis原创 2015-12-28 14:00:54 · 406 阅读 · 0 评论 -
[leetcode] 160. Intersection of Two Linked Lists 解题报告
题目链接:https://leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following原创 2015-12-28 15:20:22 · 525 阅读 · 0 评论 -
[leetcode] 234. Palindrome Linked List 解题报告
题目链接:https://leetcode.com/problems/palindrome-linked-list/Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?思路:如果不限制O(1)原创 2015-12-19 15:27:52 · 924 阅读 · 0 评论 -
[leetcode] 138. Copy List with Random Pointer 解题报告
题目链接:https://leetcode.com/problems/copy-list-with-random-pointer/A linked list is given such that each node contains an additional random pointer which could point to any node in the list or nul原创 2016-01-11 01:12:22 · 782 阅读 · 0 评论