- 博客(15)
- 收藏
- 关注
转载 3Sum Closest 【leetcode】
#include<string>#include<iostream>#include<stack>#include<vector>#include<set>#include<algorithm>usingna...
2015-10-13 23:00:00 99
转载 Longest Palindromic Substring
1:回文有两种方式,第一种是中间那个字符有奇数个,第二种是中间的字符有偶数个,对于每个字符,从这个字符开始,begin递减,end递增,判断s[begin]和s[end]是否相等,返回相等的子串。 2:遍历字符串中每个字符,对得到的子串进行比较,找出最大的 stringget(strin...
2015-09-29 22:26:00 89
转载 求数组中和为0的最大子数组
#include<map>#include<iostream>#include<vector>#include<set>usingnamespacestd;voidget(vector<int>a){ vecto...
2015-09-25 22:57:00 185
转载 Remove Nth Node From End of List
classSolution{public: ListNode*removeNthFromEnd(ListNode*head,intn){ if(head->next==NULL) returnNULL; ListNode*p=head; ...
2015-09-25 21:45:00 113
转载 [LeetCode] Best Time to Buy and Sell Stock I II II
转载:来自梁佳宾的网络日志 求数组中差值最大的两个数,后面的那个数要大于前面的那个数 #include<vector>#include<iostream>#include<algorithm>usingnamespacestd;//I题意:用...
2015-09-19 11:12:00 41
转载 最小生成树之Prim算法 C++实现
Prim算法大致介绍(个人理解) 1:图中所有的点组成了一个集合set,从集合set中随意选取一个点s,开始进行该算法, 2:从set中将该点s删除,并将该点s加入到另外一个集合now中,now初始为空 3:对now中的所有节点进行遍历,找到距离now的最近的那个非集合now的节点,并将...
2015-09-14 11:29:00 241
转载 深度优先搜索 dfs C++实现
#include<map>#include<iostream>#include<string>#include<vector>usingnamespacestd;staticvector<string>order;...
2015-09-13 22:21:00 151
转载 广度优先搜索bfs C++实现
#include<iostream>#include<vector>#include<map>#include<queue>#include<set>usingnamespacestd;vector&l...
2015-09-13 20:58:00 332
转载 求数组中任何连续子数组的最大和,并打印最大子数组(求开始和结束下标)
//计算数组中任何连续子数组的最大和,并打印最大子数组(求开始和结束下标)//思路:1:当数组元素全为0时,输出最大的那个负数//2:当数组有正有负时,i=0遍历数组,从大于0的那个元素开始,记录此时的下标为shart(最大子数组起始下标),从start开始遍历剩下的元素,若元...
2015-09-09 12:34:00 761
转载 删除字符串空格 C语言实现
今天上午遇到了个面试模拟题,不是很难,经常能看到这样相同或相似的题,但是突然想不到很好的办法,晚上整理下思路,写了下来 #include<stdio.h>#include<string.h>#include<stdlib.h>//删除字符串首部和尾...
2015-09-07 19:04:00 701
转载 bitset bitmap 海量数据处理
bitmap:是一个十分有用的结构。所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素。由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省。 适用范围:可进行数据的快速查找,判重,删除,一般来说数据范围是int的10倍以下 ...
2015-09-05 22:46:00 189
转载 字符串匹配-sunday算法
#include<iostream>usingnamespacestd;//匹配字符串。能匹配子串在原始字符串中所有出现的位置的开始下标,下标以0开始。intmatch(inti,intn,constchar*ori,constchar*sub){...
2015-09-05 21:29:00 101
转载 多线程小程序
#include<iostream>#include<pthread.h>#include<stdio.h>usingnamespacestd;intcon=5;pthread_mutex_ttask;pthread_cond_...
2015-09-05 16:20:00 67
转载 leetcode - 14:Longest Common Prefix
找最长公共前缀,Longest Common Prefix,自己写的小算法,并吸取他人的精华进行改进,直接上代码,第一次写难免会有疏漏,还望大家指正 #include<iostream>#include<string>#include<vector>...
2015-09-05 15:46:00 73
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人