public final class AbBase64 { /** The Constant base64EncodeChars. */ private static final char[] base64EncodeChars = new char[] {'A', 'B', '...
分类:
其他好文 时间:
2014-12-06 16:36:32
阅读次数:
167
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra ...
分类:
其他好文 时间:
2014-12-05 22:48:46
阅读次数:
139
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get ...
分类:
其他好文 时间:
2014-12-04 12:21:07
阅读次数:
128
题目
Sort a linked list in O(n log n)
time using constant space complexity.
解答
O(nlogn)时间复杂度的排序有快排、堆排、归并,一般双向链表用快排、单向链表用归并,堆排两种都可以,以下使用归并排序:
/**
* Definition for singly-linked list.
* class Li...
分类:
其他好文 时间:
2014-12-03 21:32:25
阅读次数:
138
一、原题
Sort List
Sort a linked list in O(n log n)
time using constant space complexity.
二、分析
快速排序和归并排序的时间复杂度是O(nlogn)。如果使用归并排序,在使用链表的情况下,不需要重新申请空间存放排序后的数组,可以做到空间复杂度数O(1)。我在这里使用归并排序来排序链表...
分类:
其他好文 时间:
2014-12-03 21:28:07
阅读次数:
112
Sort a linked list inO(nlogn) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * L...
分类:
其他好文 时间:
2014-12-03 12:12:42
阅读次数:
188
Today I reviewed online algorithms and summary it now.1. LRU is k-competitive;2. LFU cannot achieve a constant competitive ration;3. Randomized algori...
分类:
其他好文 时间:
2014-12-02 00:05:05
阅读次数:
177
在上一篇博文中,我们谈到了如何利用共享内存来实现线程协作的问题。本篇博文我们主要来谈谈如何利用常量内存和纹理内存来提高程序性能。
Jeremy Lin
常量内存
所谓的常量内存,从它的名字我们就可以知道,它是用来保存在核函数执行期间不会发生变化的数据。NVIDIA硬件提供了64KB的常量内存,并且常量内存采用了不同于标准全局内存的处理方式。在某些情况下,用常量内存来替换全局内存可以有效地减少内存带宽。
常量内存的声明方式与共享内存是类似的。要使用常量内存,则需要在变量前面加上 __constant__修饰符...
分类:
其他好文 时间:
2014-11-29 23:08:00
阅读次数:
541
Sort ListSort a linked list in O(n log n) time using constant space complexity.使用Merge Sort, 空间复杂度是 O(logN) 因为使用了栈空间。SOLUTION 1:使用Merge Sort来解决问题。为什么不...
分类:
其他好文 时间:
2014-11-29 21:28:58
阅读次数:
203
序号方法说明1指定web应用默认编码集,相当调用HttpServletRequest的setCharacterEncoding方法2指定需要struts2处理请求后缀,该属性默认值是action,即所有请求*.action由struts2处理。如用户需要指定多个后缀,则后缀之间用英文逗号隔开。3设置...
分类:
其他好文 时间:
2014-11-29 14:31:15
阅读次数:
212