码迷,mamicode.com
首页 >  
搜索关键字:next permutation    ( 15663个结果
(java) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ListNode next; 6 * ListNode(int x) { 7 * ...
分类:编程语言   时间:2014-07-16 17:45:41    阅读次数:226
两个有序链表连接(归并排序中用到的)
刚才写了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
【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]Populating Next Right Pointers in Each Node
[LeetCode]Populating Next Right Pointers in Each Node...
分类:其他好文   时间:2014-07-16 11:29:23    阅读次数:143
【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
链表(一)——创建一个最基本的单向链表
1.结点 链表中用来存储一个数据的存储单元。 一个链表至少需要由两部分组成,就是数据域和指针域,一般形式的结点定义为: struct node {     Elem data; //Elem类型泛指基本数据类型     struct node *next; } typedef struct node Elemsn; 以上两步等价于: typedef struct node {...
分类:其他好文   时间:2014-07-15 13:01:24    阅读次数:281
leetcode——Insertion Sort List 对链表进行插入排序(AC)
Sort a linked list using insertion sort. class Solution { public: ListNode *insertionSortList(ListNode *head) { if(head == NULL || head->next == NULL) return head; Lis...
分类:其他好文   时间:2014-07-15 12:22:53    阅读次数:244
lua中的pairs和ipairs区别
pairs Returns three values: the next function, the table t, and nil, so that the construction for k,v in pairs(t) do body end will iterate over all key–value pairs of table t. See functi...
分类:其他好文   时间:2014-07-14 18:39:58    阅读次数:317
Android中的双向链表
1.看源码必须搞懂Android的数据结构。在init源代码中双向链表listnode使用很多,它只有prev和next两个指针,没有任何数据成员。这个和linux内核的list_head如出一辙,由此可见安卓深受linux内核的影响的。本来来分析一下这个listnode数据结构。 这里需要考虑的一个问题是,链表操作都是通过listnode进行的,但是那不过是个连接件,如果我们手上有个宿主结构,...
分类:移动开发   时间:2014-07-14 18:13:24    阅读次数:435
【leetcode刷题笔记】Insertion Sort List
Sort a linked list using insertion sort.题解:实现链表的插入排序。要注意的地方就是,处理链表插入的时候尽量往当前游标的后面插入,而不要往前面插入,后者非常麻烦。所以每次利用kepeler.next.val和head.val比较大小,而不是kepeler.val...
分类:其他好文   时间:2014-07-14 17:47:19    阅读次数:207
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!