码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
LeetCode OJ-- Sort List **@
链表排序,要求使用 O(nlgn) 时间,常量空间。使用归并的思路/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int ...
分类:其他好文   时间:2014-08-16 15:02:00    阅读次数:162
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place....
分类:其他好文   时间:2014-08-16 12:39:00    阅读次数:136
[leetcode]Convert Sorted List to Binary Search Tree
Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST....
分类:其他好文   时间:2014-08-16 12:19:20    阅读次数:227
Leetcode--Reorder List
Problem Description: 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...
分类:其他好文   时间:2014-08-15 22:34:39    阅读次数:330
Leetcode--Flatten Binary Tree to Linked List
Problem Description: Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / 2 5 / \ 3 4 6 The flattened tree sho...
分类:其他好文   时间:2014-08-15 10:43:28    阅读次数:198
【Leetcode长征系列】Merge k Sorted Lists
原题: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:两条两条地合并。时间复杂度为O(n),n为所有链表节点和。 代码: /** * Definition for singly-linked list. * struct List...
分类:其他好文   时间:2014-08-14 20:52:09    阅读次数:275
Linked List Cycle
这个题目就是用两个指针遍历链表,一个指针每次跳一步,另外一个指针每次跳两步,如果重合,则说明有环。 1 #define NULL 0 2 3 class Solution { 4 public: 5 bool hasCycle(ListNode *head) { 6 Lis...
分类:其他好文   时间:2014-08-14 19:27:19    阅读次数:185
[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...
分类:其他好文   时间:2014-08-14 01:01:07    阅读次数:230
[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 o...
分类:其他好文   时间:2014-08-14 00:56:47    阅读次数:199
Leetcode--Sort List
Problem Description: Sort a linked list in O(n log n) time using constant space complexity. 分析:对链表进行排序,思考排序算法时间复杂度为O(nlogn)的只有归并,快排和堆排序,应用到链表上的归并比较合适,这里利用快慢指针找到链表的中间节点,然后分别对两边递归归并排好序后将两边归并即可得到最终...
分类:其他好文   时间:2014-08-13 22:25:57    阅读次数:234
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!