leetcode链表
文章平均质量分 67
葱shen
爱技术,爱学习,爱游戏~
展开
-
[leetcode] 【链表】2. 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 single digit. Add the two numbers and return it as a link原创 2016-05-30 11:12:49 · 181 阅读 · 0 评论 -
[leetcode] 【链表】143. 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' values.For example,Given {1,2,3,4}, reorder it t原创 2016-06-03 16:09:31 · 282 阅读 · 0 评论 -
[leetcode] 【链表】142. 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.Follow up:Can you solve it without using extra space?原创 2016-06-02 16:13:25 · 267 阅读 · 0 评论 -
[leetcode] 【链表】141. 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-06-02 16:05:49 · 218 阅读 · 0 评论 -
[leetcode] 【链表】 138. 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 null.Return a deep copy of the list.题意 一个链表包含额外的随机指针,这个指针指向任意节原创 2016-06-02 10:33:00 · 181 阅读 · 0 评论 -
[leetcode] 【链表】25. 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 multiple of k then left-out nodes in the end should remain as it is原创 2016-06-02 00:31:21 · 196 阅读 · 0 评论 -
[leetcode] 【链表】24. 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->1->4->3.Your algorithm should use only constant space. Y原创 2016-06-01 22:01:05 · 197 阅读 · 0 评论 -
[leetcode] 【链表】19. 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->3->4->5, and n = 2. After removing the second node from the end, the原创 2016-06-01 16:56:47 · 272 阅读 · 1 评论 -
[leetcode] 【链表】 61. 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->1->2->3->NULL.题意把链表后k个节点翻转到链表头,比如1->2->3-原创 2016-06-01 16:06:47 · 199 阅读 · 0 评论 -
[leetcode] 【链表】 82. 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 list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1原创 2016-05-30 17:28:26 · 176 阅读 · 0 评论 -
[leetcode] 【链表】83. 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, return 1->2.Given 1->1->2->3->3, return 1->2->3.题意一个排好序的链表,把 里面的重复元原创 2016-05-30 17:04:32 · 213 阅读 · 0 评论 -
[leetcode] 【链表】86. 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 preserve the original relative order of the nodes in each of原创 2016-05-30 16:43:35 · 210 阅读 · 0 评论 -
[leetcode] 【链表】92. 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,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the原创 2016-05-30 15:40:10 · 281 阅读 · 0 评论 -
[leetcode] 【链表】 146. LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2016-06-03 21:18:23 · 272 阅读 · 0 评论