码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
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 e...
分类:其他好文   时间:2014-09-07 13:27:15    阅读次数:230
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 removi...
分类:其他好文   时间:2014-09-06 16:00:53    阅读次数:189
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 alg...
分类:其他好文   时间:2014-09-06 13:39:03    阅读次数:177
【LeetCode】Insertion Sort List
Insertion Sort ListSort a linked list using insertion sort.本题是插入排序的链表版本。传统数组版本做法就是两重循环,第一重是遍历所有元素,第二重是遍历已排序部分进行插入。链表版本类似,在遍历每个元素过程中,遍历已排序部分进行插入。上代码,代码...
分类:其他好文   时间:2014-09-06 13:34:23    阅读次数:162
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 le...
分类:其他好文   时间:2014-09-06 12:20:23    阅读次数:171
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 s...
分类:其他好文   时间:2014-09-05 19:57:31    阅读次数:205
Leetcode--Convert Sorted List to Binary Search Tree
Problem Description: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 分析:很容易想到的一种解法是将链表中所有的元素保存到数组中,然后每次取中间值进行构造,时间复杂度为O(n),空间复杂度为O(n)。具体...
分类:其他好文   时间:2014-09-05 18:14:11    阅读次数:223
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-09-05 12:53:01    阅读次数:260
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-09-05 05:31:40    阅读次数:176
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-09-05 05:31:30    阅读次数:224
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!