虽然MongoDB的索引在存储结构上都是一样的,但是根据不同的应用层需求,还是分成了唯一索引(unique)、稀疏索引(sparse)、多值索引(multikey)等几种类型。唯一索引唯一索引在创建时加上 unique:true 的选项即可,创建命令如下:db.users.ensureIndex({...
分类:
数据库 时间:
2014-07-24 21:37:42
阅读次数:
299
Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen...
分类:
其他好文 时间:
2014-07-24 21:24:16
阅读次数:
296
刘汝佳书上用的是set,
通过集合来查找.count()和删除.erase().这个方法比我的要好,用时更短。
我觉得map也能完成这个任务,但是其删除并不方便,需要先查找find()下标,然后删除此下标对应的元素
但是map有map的用法,下面的方法就是比较容易实现的一种方法。
我本想着这个一边读完就计算出了ans,应该更快一点的,但是事实上还不如先读再用set处理来得快。
#incl...
分类:
其他好文 时间:
2014-07-24 17:36:36
阅读次数:
227
真心大水题。。。不多说。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 #define typec int11 using namespace ...
分类:
其他好文 时间:
2014-07-24 17:18:35
阅读次数:
217
更改成实形数即可。第一次敲完直接交,CE了一次。晕。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 #define typec double11...
分类:
其他好文 时间:
2014-07-24 16:58:35
阅读次数:
209
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 1
\...
分类:
编程语言 时间:
2014-07-24 11:35:42
阅读次数:
245
Borg Maze
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 8250
Accepted: 2762
Description
The Borg is an immensely powerful race of enhanced humano...
分类:
其他好文 时间:
2014-07-24 10:30:03
阅读次数:
393
这题在Unique Paths的基础上增加了一些obstacle的位置,应该说增加的难度不大,但是写的时候对细节的要求多了很多,比如,第一列的初始化会受到之前行的第一列的结果的制约。另外对第一行的初始化,也要分if else赋值。很容易出现初始化不正确的情况。 代码: class Solut...
分类:
其他好文 时间:
2014-07-24 05:06:08
阅读次数:
221
Permutation SequenceThe set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the fo...
分类:
其他好文 时间:
2014-07-23 22:11:47
阅读次数:
327
无坑,裸题。直接敲就恩那个AC。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 #define typec int10 using namespace std;11 1...
分类:
其他好文 时间:
2014-07-23 15:15:06
阅读次数:
220