链表
文章平均质量分 76
haryssblog
这个作者很懒,什么都没留下…
展开
-
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. pro:从排序li sol: code:原创 2014-07-12 13:42:45 · 272 阅读 · 0 评论 -
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原创 2014-07-12 21:56:29 · 293 阅读 · 0 评论 -
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.原创 2014-07-12 17:21:19 · 290 阅读 · 0 评论 -
Copy List with Random Pointer
pro: sol: code:原创 2014-07-12 12:37:53 · 300 阅读 · 0 评论 -
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原创 2014-07-12 17:39:05 · 218 阅读 · 0 评论 -
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. pro:给一个lian sol: code:原创 2014-07-12 16:37:35 · 297 阅读 · 0 评论 -
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原创 2014-07-12 13:39:13 · 423 阅读 · 0 评论 -
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 t原创 2014-07-12 16:02:22 · 243 阅读 · 0 评论 -
Linked List Cycle I&&II
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? pro code: /** * Definition for singly-linked list. * struct ListNode {原创 2014-07-12 11:59:32 · 285 阅读 · 0 评论 -
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原创 2014-07-12 22:31:46 · 242 阅读 · 0 评论 -
Leetcode linked list
Insertion Sort List pro:Sort a linked list using insertion sort.原创 2014-07-12 11:58:43 · 297 阅读 · 0 评论 -
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->1-原创 2014-07-12 14:14:31 · 465 阅读 · 0 评论 -
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 lists. pro:将两个 sol: code:原创 2014-07-12 14:25:39 · 344 阅读 · 0 评论 -
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原创 2014-07-12 22:41:52 · 246 阅读 · 0 评论