Sort a linked list inO(nlogn) time using constant space complexity.findMiddle: 将listnode 不停的拆分sort: 将拆分好的不同的sortmerge: 将sort好的,向上merge/** * Definition...
分类:
其他好文 时间:
2015-03-08 07:50:33
阅读次数:
128
在开发过程中,多环境配置是经常遇到的,比如在Android开发过程中,在不同环境上请求服务器的URL是不同的,使用Gradle进行管理,是非常方便的。
首先查看工程目录结构:
使用AndroidStudio开发的看到这个熟悉吧。main就是目前开发的环境。dev为测试环境。product,staging为其他环境,当然还可以有其他更多环境。1、将请求的URL定义到Constant常量类中...
分类:
Web程序 时间:
2015-03-06 17:07:47
阅读次数:
144
1.题目Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may...
分类:
其他好文 时间:
2015-03-06 10:02:54
阅读次数:
139
The motivation during your PhD is not constant, and it resembles the phases that entrepreneurs experience and that Tim Ferriss describes in his postHa...
分类:
其他好文 时间:
2015-03-05 16:38:18
阅读次数:
146
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
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