注:以下源码基于jdk1.7.0_11
之前的几篇文章介绍了List集合中一些比较常见的类,比如ArrayList、LinkedList、Vector等。本篇文章将介绍集合框架的另一块内容——Map集合。本文主要介绍HashMap。
先回顾下哈希表。
哈希表定义:根据设定的hash函数和处理冲突的方式(开放定址、公共溢出区、链地址、重哈希...)将一组关键字映...
分类:
其他好文 时间:
2014-08-14 10:57:28
阅读次数:
373
#include"stdio.h"
#include"string.h"
#include"vector"
using namespace std;
#define N 11000
const int inf=1<<20;
vectorg[N];
int s,t,n;
int f[N],pre[N],ans[N];
bool vis[N];
int findset(int x)
{
if(...
分类:
其他好文 时间:
2014-08-13 22:30:17
阅读次数:
252
很水,但是需要练速度反映。。。15分钟全部写对!!!!!!!!!!!!
#include
#include
#include
using namespace std;
class Decimal {
public:
int integer;
bool recycle;
vector decimal;
};
void toDecimal(int dividend, ...
分类:
其他好文 时间:
2014-08-13 22:28:47
阅读次数:
277
Redundant Paths
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 9118
Accepted: 3925
Description
In order to get from one of the F (1 <= F <= 5,000) grazing...
分类:
其他好文 时间:
2014-08-13 19:03:27
阅读次数:
264
题目链接:点击打开链接
题意:
第一行 n m
n个vector
下面n行 第一个数字u表示vector 的大小,然后后面u个数字给出这个vector
最后一行m个数字
表示把上面的vector拼接起来
得到一个大序列,求这个大序列的最大子段和
先预处理出每个vector的最大子段和,左起连续最大,右起连续最大,所有数的和
然后dp 一下。。
#include ...
分类:
其他好文 时间:
2014-08-13 18:55:07
阅读次数:
266
bfs基础算法水题
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int Max = 1e5+50;
int dist[Max];
vector tree[Max];
int N, D, T;
void init()
{
for(int i = 0; ...
分类:
其他好文 时间:
2014-08-13 14:56:06
阅读次数:
187
将所有密度遍历一遍求最小即可
#include
using namespace std;
struct CandyMaking {
double findSuitableDensity(vector containerVolume, vector desiredWeight) {
vectorv;
double Min=50000000;
...
分类:
其他好文 时间:
2014-08-13 10:31:55
阅读次数:
216
Just take care of corner cases!class Solution {public: vector fullJustify(vector &words, int L) { vector ret; int startInx = 0; ...
分类:
其他好文 时间:
2014-08-13 10:17:25
阅读次数:
174
1 class Solution { 2 public: 3 vector postorderTraversal(TreeNode *root) { 4 if(root->left == NULL && root->right == NULL) 5 { 6 ...
分类:
其他好文 时间:
2014-08-13 10:16:05
阅读次数:
168
前面两篇介绍了gcc4.8的vector和list的源码实现,这是stl最常用了两种序列式容器。除了容器之外,stl还提供了一种借助容器实现特殊操作的组件,谓之适配器,比如stack,queue,priority queue等,本文就介绍gcc4.8的priority queue的源码实现。顾名思义...
分类:
其他好文 时间:
2014-08-13 01:06:44
阅读次数:
288