码迷,mamicode.com
首页 >  
搜索关键字:listnode    ( 1413个结果
寻找带环的链表的柄长
试题:给定一个带环的链表,找出环起点。比如:A -> B -> C -> D -> E -> C (C为环形起点)写一个程序找出环起点C。ListNode结构如下,请实现 ListNode* find_circle_beginning(ListNode* head);函数,返回环的起点。struct...
分类:其他好文   时间:2014-07-10 00:14:17    阅读次数:232
Problem Insertion Sort List
Problem Description:Sort a linked list using insertion sort.Solution: 1 public class Solution { 2 public ListNode insertionSortList(ListNode head)...
分类:其他好文   时间:2014-07-07 16:57:55    阅读次数:117
Problem Sort List
Problem Description:Sort a linked list inO(nlogn) time using constant space complexity.Solution: 1 public ListNode sortList(ListNode head) { 2 ...
分类:其他好文   时间:2014-07-07 16:48:00    阅读次数:238
Leetcode:Sort List 对单链表归并排序
Sort a linked list in O(n log n) time using constant space complexity. 看到O(n log n)的排序算法,适合单链表的首先想到的就是归并排序 /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis...
分类:其他好文   时间:2014-07-02 08:47:34    阅读次数:239
算法题之二(从尾到头打印链表)
链表节点定义如下:1 typedef struct ListNode2 {3 int value;4 ListNode *next;5 }TListNode;众所周知,链表打印时从头到尾很简单,所以我们首先想到的可能是先把链表逆序,然后从头到尾再打印出来即可,但是逆序会破坏链表的结构...
分类:其他好文   时间:2014-07-01 11:54:59    阅读次数:168
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? 方法 /** * Definition for singly-linked list. * class ListNode { ...
分类:其他好文   时间:2014-07-01 11:31:40    阅读次数:178
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? 方法 public ListNode de...
分类:其他好文   时间:2014-07-01 11:30:58    阅读次数:200
【剑指offer】从尾到头打印链表
题目描述: 输入一个链表的头结点,从尾到头反过来打印出每个结点的值。链表结点定义如下: struct ListNode{ int m_nKey; ListNode *m_pNext; }; 分析描述: 对于链表,如果是从头到尾的打印出链表是比较容易,但如果是从尾到头返过来打印每个结点的值就比较复杂。反序输出就是第一个遍历到的结点最后一个输出,而最后一个遍历的结点第一个输出。...
分类:其他好文   时间:2014-07-01 10:59:13    阅读次数:163
LeetCode Partition List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *...
分类:其他好文   时间:2014-06-30 23:36:56    阅读次数:211
LeetCode Reverse Linked List II
class Solution {public: ListNode *reverseBetween(ListNode *head, int m, int n) { if (head == NULL || n 0) { pre = cur; ...
分类:其他好文   时间:2014-06-30 15:36:26    阅读次数:148
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!