class Solution { public: vector >
permuteUnique(vector &num) { vector > result; if (num.size() path;
dfs(n...
分类:
其他好文 时间:
2014-06-29 14:09:34
阅读次数:
220
class Solution { public: vector
spiralOrder(vector > &matrix) { vector ret; int cols = 0; ...
分类:
其他好文 时间:
2014-05-28 14:38:02
阅读次数:
236
class Solution { public: vector >
generateMatrix(int n) { vector > matrix; if (n (n, 0)); }...
分类:
其他好文 时间:
2014-05-28 09:42:14
阅读次数:
233
上一篇文章《STL系列》之vector原理及实现,介绍了vector的原理及实现,这篇文章介绍map的原理及实现。STL实现源码下载。STL中map的实现是基于RBTree的,我在实现的时候没有采用RBTree,觉得这东西有点复杂,我的map采用的是排序数组(CSortVector)。map中的Ke...
分类:
其他好文 时间:
2014-05-27 16:53:47
阅读次数:
338
第1章
容器第1条:慎重选择容器类型。标准STL序列容器:vector、string、deque和list。标准STL关联容器:set、multiset、map和multimap。非标准序列容器slist和rope。slist是一个单向链表,rope本质上是一“重型”string。非标准的关联容器h...
分类:
编程语言 时间:
2014-05-26 08:14:34
阅读次数:
384
有序容器:vector[连续内存]
拥有一段连续的地址空间,首地址不变,按顺序存放,拥有高效的随机存储和访问,毕竟有迭代器作为序号。
从尾部插入和删除很快,其他地方插入和删除操作的时间复杂度就高喽,需要大范围内存的复制粘贴,效率低下,就像数组一样.有空间预留的特点,操作起来消耗内存空间。capa.....
分类:
其他好文 时间:
2014-05-26 07:10:59
阅读次数:
244
题目一:
Given a binary tree containing digits from 0-9 only, each root-to-leaf
path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Fin...
分类:
其他好文 时间:
2014-05-26 04:06:41
阅读次数:
248
缓存(caching): 当组合结构很复杂,或者遍历的代价太高,那么实现组合节点的缓存就很有帮助。
(1) Java Collection Framework 指的是一群类的接口。 其中包括了 ArrayList, Vector , LinkedList , Stack ,和 PriorityQueue. 这些类都实现了java.util.Collection接口。
(2) Collect...
分类:
其他好文 时间:
2014-05-24 23:37:45
阅读次数:
432
题目:这个题目里要求最多交易2次。也就是说可以只交易一次,不交易也可以。
分析:将整个交易序列分割成两部分,求出这样的一种分割,使得两部分连续子序列的和相加的结果最大,当然,如果不进行分割,就是求出整个序列的最大连续子序列的和。
那么分割点就可能是任意位置。找出取得最大值的分割点,返回最大值。
int maxProfit(vector &prices) {
const int le...
分类:
其他好文 时间:
2014-05-24 20:54:57
阅读次数:
402
第6章 使用库算法
本章中主要教我们如何使用几个库算法来解决与处理字符串和学生成绩相关的问题。
1、分析字符串
使用一个循环来连接两幅字符图案
for(vector::const_iterator it = bottom.begin(); it != bottom.end(); ++it)
ret.push_back(*it);
等价于
ret.insert(ret.end(...
分类:
编程语言 时间:
2014-05-24 20:24:10
阅读次数:
365