码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
LeetCode[Tree]: 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 6 The flattened tree should look like: 1 2 3 4 5 6 递归算法 这种问题非常适合用...
分类:其他好文   时间:2014-12-02 15:19:59    阅读次数:168
[LeetCode] Linked List Cycle 单链表中的环
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?开始以为这道题只需要注意不使用额外空间即可,于是写了个时间复杂度为O(n^2)暴力...
分类:其他好文   时间:2014-12-02 14:56:30    阅读次数:177
[LeetCode] Linked List Cycle II 单链表中的环之二
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space?这...
分类:其他好文   时间:2014-12-02 14:55:22    阅读次数:195
[LeetCode]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 6 The flattened tree should look like: 1 ...
分类:其他好文   时间:2014-12-01 22:36:30    阅读次数:178
[leetcode]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 left-out nodes in the end should remain ...
分类:其他好文   时间:2014-12-01 22:32:51    阅读次数:230
[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->3->3->4->4->5, return 1->2->5. Giv...
分类:其他好文   时间:2014-12-01 22:31:26    阅读次数:221
leetcode Flatten Binary Tree to Linked List
题目:给定一个棵树,将其转换成flattened tree。只有右节点的,类似于链表,且在原址操作。例如:Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look l...
分类:其他好文   时间:2014-11-30 18:38:38    阅读次数:209
Insertion Sort List --leetcode
思路:创建一辅助节点,作为生成链表的头结点(不含有效数据)。遍历原链表中每一个节点,并将其插入到新链表的对应位置/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL...
分类:其他好文   时间:2014-11-30 09:16:32    阅读次数:210
LeetCode: Linked List Cycle 解题报告
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?SOLUTION 1:经典快慢指针问题。如果存在环...
分类:其他好文   时间:2014-11-30 00:15:56    阅读次数:262
leetcode Convert Sorted List to Binary Search Tree
把一个有序链表构成成平衡二叉树。和上一题有一点像。思路一:将有序链表存在一个数组里。然后根据每次访问中间节点当做根节点递归左右子树节点即可。代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:其他好文   时间:2014-11-29 22:53:04    阅读次数:271
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!