码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
[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?算法思路1:快慢指针,当两个指针相遇,则表示有环,...
分类:其他好文   时间:2014-07-19 18:38:30    阅读次数:198
[leetcode]Linked List Cycle II
Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u...
分类:其他好文   时间:2014-07-19 18:18:51    阅读次数:270
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-07-19 11:47:54    阅读次数:168
【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 6The flattened t...
分类:其他好文   时间:2014-07-19 00:24:36    阅读次数:170
【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-07-18 00:32:24    阅读次数:271
两个有序链表连接(归并排序中用到的)
刚才写了k个,顺手写个2个的,在链表的归并排序中很有用,效率非常好 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ListNode next;...
分类:其他好文   时间:2014-07-16 17:42:41    阅读次数:275
[cc150] check palindrome of a singly linked list
Problem: Implement a function to check if a singly linked list is a palindrome.思路:最简单的方法是 Reverse and compare.另外一种非常经典的办法是用 Recursive 的思路,把一个list看成这种形...
分类:其他好文   时间:2014-07-16 17:41:23    阅读次数:188
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. Given 1->1-...
分类:其他好文   时间:2014-07-16 17:30:52    阅读次数:230
【leetcode】Linked List Cycle (python)
题目分析见这里 class Solution: # @param head, a ListNode # @return a list node def detectCycle(self, head): if None == head or None == head.next: return None pfast = ...
分类:编程语言   时间:2014-07-16 17:18:53    阅读次数:248
【leetcode】Linked List Cycle (python)
class Solution: # @param head, a ListNode # @return a boolean def hasCycle(self, head): if None == head or None == head.next: return False pfast = head ...
分类:编程语言   时间:2014-07-16 09:50:21    阅读次数:271
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!