- 博客(10)
- 资源 (7)
- 收藏
- 关注
原创 平方探测哈希表
#include #include #include #include using namespace std; template class HashTable{public: explicit HashTable(int size=101) :theSize(nextPrime(size)),array(nextPrime(size)) { makeEmpt
2015-05-25 20:19:24 578
原创 单链表反转
#include #include using namespace std;templateclass linkList{private: struct Node { Object data; Node *next; Node(const Object &d=Object{ },Node *n=nullptr) :data(d),next(n) { }
2015-05-20 14:26:22 443
原创 线性时间选出一个数组中第i大的数
利用快排的partition,在线性时间内,选择出第i大的数templateint qPartition(vector &vec,int p,int r){ uniform_int_distribution u(p,r); default_random_engine e(32676); int pos=u(e); std::swap(vec[pos],vec[r]); int key
2015-05-19 17:48:44 501
原创 算法导论6.5-9,K个有序链表合并 nlgn
#include #include #include #include using namespace std;templateclass minKList{public: explicit minKList(int capacity=100) :array(capacity+1),currentSize(0) { } explicit minKList(const
2015-05-18 12:27:40 670
原创 lost in city (修改后,时间大幅度减少,所以系统的find函数还是挺耗时的)
#include #include #include #include #include using namespace std;bool isPattern(const string &str1,const string &str2){ if(str1.length()==str2.length()) { for(int i=0;i<str1.length();i+
2015-05-07 18:45:09 455
原创 lost in the city(超时了...)
#include #include #include #include #include using namespace std;bool isPattern(const string &str1,const string &str2){ if(str1.length()==str2.length()) { for(int i=0;i<str1.length();i+
2015-05-07 18:28:17 388
原创 算法导论2.3.7
利用二分查找的复杂度为logN,所以查找对象为binarySearch(vec,vec[i])做一个循环即可bool findSum(const vector &vec,vector &result,int v){ vector vec2(vec); sort(vec2.begin(),vec2.end()); int idx; int i; int flag=0; fo
2015-05-06 14:03:12 304
原创 然而沼跃鱼早就看穿了一切(字符串匹配的题目)
fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区分大小写)。为了使句子不缺少成分,统一换成 “fjxmlhx” 。输入输入包括多行。每行是一个字符串,长度不超过200。一行的末尾与下一行的开头没有关系。输出输出包含多行,为输入按照描述中变换的结果。样例输入The Marshtomp has seen it all befo
2015-05-05 16:31:07 507
原创 为什么没通过呢
#include #include #include #include using namespace std;int month(const string &s){ istringstream stream1(s); string mon; string days; int day; stream1>>mon>>days; istringstream strea
2015-05-05 11:32:28 300
原创 微软笔试 luckyString(其中map那段是多余的,就懒的改了,刚开始以为每个字符的个数都要求是斐波拉切)
#include #include #include #include #include using namespace std;vector subString(const string &s){ vector ret; int i,j; string subs; int N=s.length(); for(i=1;i<=N;i++) { for(j=0;j
2015-05-04 22:19:28 457
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人