码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
Sort List
Sort a linked list in O(n log n) time using constant space complexity.思路:使用O(nlogn)时间复杂度和常数空间复杂度,我们想到可以用归并排序。1)找到链表中间位置2)将两个链表按序合并链表3)对所给链表进行整体的归并排序/*...
分类:其他好文   时间:2014-06-27 00:22:37    阅读次数:303
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...
分类:其他好文   时间:2014-06-26 23:07:29    阅读次数:276
Leetcode Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.TreeNode *createSearchTree(ListNode *&hea...
分类:其他好文   时间:2014-06-26 00:12:57    阅读次数:289
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-06-25 23:36:53    阅读次数:291
LeetCode Linked List Cycle
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *...
分类:其他好文   时间:2014-06-25 21:00:45    阅读次数:200
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-06-25 12:14:23    阅读次数:159
leetcode--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-06-25 11:10:16    阅读次数:163
LeetCode :: Insertion Sort List [详细分析]
Sort a linked list using insertion sort. 仍然是一个非常简洁的题目,让我们用插入排序给链表排序;这里说到插入排序,可以来回顾一下, 最基本的入门排序算法,就是插入排序了;时间复杂度为n^2,最基本的插入排序是基于数组实现的,下面给出基于数组实现的插入排序,来体会一个插入排序的思想; 以下仅为数组实现,不是解题代码,没兴趣可以跳过。 vo...
分类:其他好文   时间:2014-06-24 23:56:31    阅读次数:359
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 t...
分类:其他好文   时间:2014-06-24 21:55:30    阅读次数:279
LeetCode || Copy List with Random Pointer
Copy List with Random Pointer Total Accepted: 12730 Total Submissions: 56262 My Submissions A linked list is given such that each node contains an additional random pointer which could poi...
分类:其他好文   时间:2014-06-24 19:32:26    阅读次数:194
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!