Given an unsorted integer array, find the first missing positive integer.
For example,
Given [1,2,0] return 3,
and [3,4,-1,1] return 2.
Your algorithm should run in O(n) time and uses constant...
分类:
其他好文 时间:
2015-03-04 21:08:58
阅读次数:
131
众所周知,在Unity游戏开发的过程中经常会创建一些新的对象,如果数量较少还可以接受,如果创建的新对象数量庞大,那么对内存而言是一个极大的隐患。例如射击游戏当中,每发射一颗子弹,都要创建一个新的子弹对象,那么子弹是数量庞大,可想而知一场游戏当中会创建多少这样的新对象,那么如果这些子弹创建之后都对游戏...
分类:
编程语言 时间:
2015-03-04 19:01:08
阅读次数:
219
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.
- to...
分类:
其他好文 时间:
2015-03-04 16:54:14
阅读次数:
179
Hypertextpreprocessor超文本预处理语言Define定义Undefined未定义的Constant常量Variable变量Global全球的、总体的static静态、静止的server服务器value值、数值request请求type类型string字符串int整数integer整数、整型、整数型long长整型float浮点数double双精度型Boolean..
分类:
Web程序 时间:
2015-03-04 06:17:35
阅读次数:
216
Sort a linked list in O(n log n)
time using constant space complexity.
链表排序,O(nlgn)的复杂度,应该是归并或者快排,对链表来说归并应该用起来更顺手一些,尤其是对归并的步骤来说,链表这种数据结构真是再合适不过了。这里我用了递归调用来实现归并步骤,效率可能略微低那么一点点,但是代码简洁得不得了哇~~
归并排序是分治...
分类:
其他好文 时间:
2015-03-03 22:18:35
阅读次数:
160
常量(Constant):是一种标识符,它的值在运行期间恒定不变。并且常量在程序中只能被引用,而不能被重新赋值。按类型可分为: 数据型: 整数型:用来存储整数 short(占二字节) int(占四字节) long(占八字节) 浮点型:用来存储小数 float(占四字节) double(...
分类:
编程语言 时间:
2015-03-03 15:00:23
阅读次数:
175
很久之前就遇到这个问题了,今天又踩坑...如果想在C语言里面产生随机数,需要调用rand()
Description The C library function int rand(void) returns a pseudo-random number in the range of 0 to RAND_MAX. RAND_MAX is a constant whose default v...
分类:
其他好文 时间:
2015-03-02 16:57:47
阅读次数:
143
目录目录
题目
思路1
AC代码
缺陷
思路2
AC代码题目
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 ele...
分类:
其他好文 时间:
2015-03-02 13:08:54
阅读次数:
141
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 ...
分类:
其他好文 时间:
2015-02-28 18:45:25
阅读次数:
116
内存池(Memory Pool)是一种内存分配方式。 通常我们习惯直接使用new、malloc等API申请分配内存,这样做的缺点在于:由于所申请内存块的大小不定,当频繁使用时会造成大量的内存碎片并进而降低性能。内存池则是在真正使用内存之前,先申请分配一定数量的、大小相等(一般情况下)的内存块留作备用。当有新的内存需求时,就从内存池中分出一部分内存块,若内存块不够再继续申请新的内存。这样做的一个显著优点是尽量避免了内存碎片,使得内存分配效率得到提升。
(1)针对特殊情况,例如需要频繁分配释放固定大小的内存对象...
分类:
其他好文 时间:
2015-02-27 21:36:28
阅读次数:
244