码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
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. 思路:遍历链表,通过两个指针...
分类:其他好文   时间:2014-10-28 12:12:23    阅读次数:143
[LeetCode] Reverse Linked List II
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:其他好文   时间:2014-10-28 11:41:46    阅读次数:147
【Leetcode】Partition List (Swap)
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-10-28 10:29:07    阅读次数:204
LeetCode - Linked List Cycle
判断一个链表是否为循环链表。 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x...
分类:其他好文   时间:2014-10-27 22:49:16    阅读次数:154
LeetCode-Reverse Nodes in k-Group
Given this linked list:1->2->3->4->5Fork= 2, you should return:2->1->4->3->5Fork= 3, you should return:3->2->1->4->5思路:一开始是想要动态规划的方式,即写一个反转函数,每K个字符调用一...
分类:其他好文   时间:2014-10-27 10:48:04    阅读次数:201
Remove Nth Node From End of List
需要额外添加两个相距为n的节点,遍历一遍之后就可以得到结果。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(in...
分类:其他好文   时间:2014-10-27 00:21:55    阅读次数:275
Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o...
分类:其他好文   时间:2014-10-26 15:30:30    阅读次数:159
LeetCode-Sort List
Sort a linked list inO(nlogn) time using constant space complexity.链表排序。要达到nlogn的时间复杂度,能想到归并排序与快速排序。这里采用归并排序: 1 /** 2 * Definition for singly-linked ....
分类:其他好文   时间:2014-10-26 10:17:34    阅读次数:186
Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi...
分类:其他好文   时间:2014-10-25 15:47:52    阅读次数:225
Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu...
分类:其他好文   时间:2014-10-24 18:10:21    阅读次数:236
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!