码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
Linked list cycle
Given a linked list, determine if it has a cycle in it. (Without using eatra space)//Solution: define two pointers, one moves one step each time while...
分类:其他好文   时间:2014-11-20 13:31:10    阅读次数:181
Leetcode: 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-11-19 20:32:41    阅读次数:129
异或链表(XOR linked list)
异或链表(Xor Linked List)也是一种链式存储结构,它可以降低空间复杂度达到和双向链表一样目的,任何一个节点可以方便的访问它的前驱节点和后继结点。可以参阅wiki 普通的双向链表 class Node { public: int data; Node *prev; Node *next;...
分类:其他好文   时间:2014-11-19 20:24:07    阅读次数:511
【Leetcode】Remove Duplicates from Sorted List in JAVA
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. 思路很简单,由于乖乖的sort好了,就是判断下...
分类:编程语言   时间:2014-11-19 18:51:28    阅读次数:242
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:其他好文   时间:2014-11-19 18:31:49    阅读次数:137
Swap Nodes in Pairs(链表操作)
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:其他好文   时间:2014-11-19 15:41:29    阅读次数:165
LeetCode Remove Duplicates from Sorted List 删除有序链表中的重复结点
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
分类:其他好文   时间:2014-11-19 13:51:14    阅读次数:222
LeetCode Solutions : Sort List
Sort a linked list inO(nlogn) time using constant space complexity.O(nlogn),我们可以第一时间想到常用的二路归并排序,快速排序和堆排序,其中快排和堆排只适用于线性表,即数组,故这道编程题毫无疑问用二路归并排序;* 1. 利用一...
分类:其他好文   时间:2014-11-19 07:24:33    阅读次数:225
Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2014-11-19 07:18:17    阅读次数:236
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:其他好文   时间:2014-11-19 00:15:33    阅读次数:284
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!