Java中把存储区分为6类。分别为寄存器(register)、栈(stack)、堆(heap)、静态存储区(static storage)、常量存储区(constant storage)以及非随机存取存储区(Non-RAM)。1. 寄存器(register).寄存器与其他的存储区不同,它位于CPU中...
分类:
编程语言 时间:
2015-03-29 19:28:26
阅读次数:
188
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 space.思路分析:...
分类:
其他好文 时间:
2015-03-29 13:39:00
阅读次数:
106
https://leetcode.com/problems/sort-list/Sort a linked list inO(nlogn) time using constant space complexity.解题思路:常见的O(nlogn)算法,快速排序、归并排序,堆排序。大概讲讲优缺点,在数...
分类:
其他好文 时间:
2015-03-28 21:32:10
阅读次数:
114
problem:
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 spa...
分类:
其他好文 时间:
2015-03-20 18:37:47
阅读次数:
123
Sort a linked list inO(nlogn) time using constant space complexity.Hide TagsLinked ListSort 基于单项链表的排序,时间为nlogn ,O(1)空间,其实及将数组的快速排序用链表实现,并用递归来维护拆分与合并。....
分类:
编程语言 时间:
2015-03-20 14:13:30
阅读次数:
135
常量可以理解为值不变的量,常量被定义后,在脚本的其他任何地方都不能改变,一个常量由英文字母,下划线,和数字组成,但是数字不能作为常量的首字母。
在php中使用#define()函数来定义常量,该函数的语法格式如下:
define(string constant_name,mixed value,case_sensitive=true)
获取常量的值的方法有两种,一种方法是:使用常量的...
分类:
Web程序 时间:
2015-03-18 09:02:35
阅读次数:
149
高级迭代器可以实现多种有价值功能。本节将展示如何利用高级迭代器和标准Thrust算法处理一个更广泛的类问题。对于那些熟悉的Boost C ++库的开发者,他们会发现Thrust的高级迭代器与Boost迭代器库非常相似。constant_iterator常量迭代器最明显的特点,是每次解引用时,都会返回...
分类:
其他好文 时间:
2015-03-17 19:53:48
阅读次数:
258
Sort a linked list in O(n log n) time using constant space complexity.
这道题是要求对单链表进行排序,有个O(nlogn)的时间复杂度的要求。我的想法是采取类似头插法的方式,遍历链表结点,设3个指针,min指向当前链表中的最小值,max指向当前链表中的最大值,cur指向前一插入的值。
min , max , cur 初始时都指向第...
分类:
其他好文 时间:
2015-03-17 15:58:02
阅读次数:
181
题目:Sort a linked list in O(n log n) time using constant space complexity.
思路:要求时间复杂度O(nlogn)
知识点:归并排序,链表找到中点的方法
存在的缺点:边界条件多考虑!!!
/**
* LeetCode Sort List Sort a linked list in O(n log n) time us...
分类:
编程语言 时间:
2015-03-16 23:14:12
阅读次数:
260
Min Stack问题:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop(...
分类:
其他好文 时间:
2015-03-15 12:05:19
阅读次数:
136