![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
likecool21
这个作者很懒,什么都没留下…
展开
-
LeetCode 刷题笔录 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原创 2013-10-02 15:04:45 · 1713 阅读 · 0 评论 -
LeetCode刷题笔录Sort List
Sort a linked list in O(n log n) time using constant space complexity. 挺有意思的题,这里用了merge sort,可以利用到merge sorted list 那题的代码 /** * Definition for singly-linked list. * class ListNode { *原创 2014-11-29 13:18:48 · 610 阅读 · 0 评论 -
LeetCode刷题笔录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->原创 2014-10-08 05:38:14 · 698 阅读 · 0 评论 -
LeetCode刷题笔录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-10-06 07:02:39 · 510 阅读 · 0 评论 -
LeetCode刷题笔录Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space?原创 2014-07-08 23:59:06 · 559 阅读 · 0 评论 -
LeetCode刷题笔录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-05-29 15:30:34 · 705 阅读 · 0 评论 -
LeetCode刷题笔录 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. 这题不能像merge原创 2014-05-29 02:22:10 · 744 阅读 · 0 评论 -
LeetCode刷题笔录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-16 04:54:43 · 548 阅读 · 0 评论 -
LeetCode刷题笔录 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. 这题xiang原创 2014-04-25 12:34:59 · 578 阅读 · 0 评论 -
LeetCode刷题笔录 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 to原创 2014-04-10 14:05:32 · 670 阅读 · 0 评论 -
LeetCode刷题笔录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. 先写了一个用extra space的方法,原创 2014-05-01 08:36:16 · 621 阅读 · 0 评论 -
Reverse A Linked List
在stackoverflow上看到一个好的方案。http://stackoverflow.com/questions/354875/reversing-a-linked-list-in-java-recursively Three questions to ask: What is the reverse of null (the empty list)? null. What转载 2014-01-03 11:48:56 · 747 阅读 · 0 评论 -
LeetCode刷题笔录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-08-02 04:52:57 · 537 阅读 · 0 评论