码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
LeetCode: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 t...
分类:其他好文   时间:2014-06-28 21:12:46    阅读次数:211
Leetcode Insertion Sort List
Sort a linked list using insertion sort.单链表的插入排序, 考查的时单链表指针的断开和插入操作#include #include #include using namespace std;struct ListNode{ int val; List...
分类:其他好文   时间:2014-06-21 12:26:49    阅读次数:206
Leetcode SortList
Sort a linked list inO(nlogn) time using constant space complexity.本题利用归并排序即可归并排序的核心是将两部分合成一部分,故开始要将链表分成两部分,利用快慢两个指针,当快指针跑到链表尾部时,慢指针恰好在中间,故可以将链表分成两部分然...
分类:其他好文   时间:2014-06-21 12:20:11    阅读次数:188
[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...
分类:其他好文   时间:2014-06-21 07:30:11    阅读次数:157
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 const...
分类:其他好文   时间:2014-06-18 11:53:39    阅读次数:138
leetcode -day30 Reverse Linked List II
1、 ?? 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....
分类:其他好文   时间:2014-06-17 23:03:12    阅读次数:257
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 rem...
分类:其他好文   时间:2014-06-17 22:15:52    阅读次数:299
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 th...
分类:其他好文   时间:2014-06-17 21:38:12    阅读次数:193
【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? 思路:由【Leetcode】Linked List Cycle可知,利用一快一慢...
分类:其他好文   时间:2014-06-15 14:23:38    阅读次数:288
leetcode——Reverse Linked List II 选择链表中部分节点逆序(AC)
处理这个问题还是挺复杂的,需要考虑很多边界的测试用例。我总体的思路是先用循环标记m前一个节点和n后边一个节点,把n后边的节点首先作为当前逆转节点的pre,然后循环n-m次完成所选节点部分的逆序,然后将标记的m节点前一个节点指向逆序后部分的头节点即可。要考虑各种特殊情况,另外考虑即可。code如下:...
分类:其他好文   时间:2014-06-15 13:44:17    阅读次数:323
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!