上一页 1 ··· 6 7 8 9 10 11 12 13 下一页
摘要: https://leetcode.com/problems/n-queens/ 1 class Solution { 2 public: 3 void dfs(vector> &ret, vector> map,int i, int j){ 4 if(i==map.size(... 阅读全文
posted @ 2015-10-22 11:23 流白 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Best Time to Buy and Sell StockTotal Accepted:69292Total Submissions:206193Difficulty:MediumSay you have an array for which theithelement is the price... 阅读全文
posted @ 2015-10-16 23:52 流白 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn=6; 8 struct edge{ 9 int to,cost; 10 e... 阅读全文
posted @ 2015-10-15 21:23 流白 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 1 struct quadruplet{ 2 int a,b,c,d; 3 quadruplet() {} 4 quadruplet(int aa,int bb,int cc,int dd){ 5 this->a=aa; this->b=bb; this->... 阅读全文
posted @ 2015-10-08 21:09 流白 阅读(167) 评论(0) 推荐(0) 编辑
摘要: //to be continue... 1 class Solution { 2 public: int* buildNext(string T){ 3 int i=1,j; 4 int *next=new int[10000000]; 5 next[... 阅读全文
posted @ 2015-10-01 12:27 流白 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main(){ 7 char a[101],b[101]; 8 int ans[220],len_ans; 9 cin>>a>>... 阅读全文
posted @ 2015-09-26 08:42 流白 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 一. KMP算法KMP算法是一种改进的字符串匹配算法,由D.E.Knuth与V.R.Pratt和J.H.Morris同时发现,简称KMP算法。KMP算法的关键是利用匹配失败后的信息,尽量减少模式串与主串的匹配次数以达到快速匹配的目的。具体实现就是实现一个next()函数,函数本身包含了模式串的局部匹... 阅读全文
posted @ 2015-02-10 11:53 流白 阅读(1125) 评论(3) 推荐(2) 编辑
摘要: 一. 什么是快速幂:快速幂顾名思义,就是快速算某个数的多少次幂。其时间复杂度为 O(log₂N), 与朴素的O(N)相比效率有了极大的提高。一般一个矩阵的n次方,我们会通过连乘n-1次来得到它的n次幂。但做下简单的改进就能减少连乘的次数,方法如下:把n个矩阵进行两两分组,比如:A*A*A*A*A*A... 阅读全文
posted @ 2015-02-09 12:44 流白 阅读(1362) 评论(1) 推荐(0) 编辑
摘要: 线段树(1)http://www.cnblogs.com/fu11211129/p/4230000.html1. 线段树应用之动态点插与统计:--------------------------------线段树(1)中讲的应用是区段的插值与统计,我们在线段树结构体中接入cover之一域,cover... 阅读全文
posted @ 2015-02-06 11:48 流白 阅读(1202) 评论(0) 推荐(2) 编辑
摘要: 一. 动态规划动态规划(dynamic programming),与“分治思想”有些相似,都是利用将问题分 为子问题,并通过合并子问题的解来获得整个问题的解。于“分治”的不同之处在 于,对于一个相同的子问题动态规划算法不会计算第二次,其实现原理是将每一个计算过的子问题的值保存在一个表中。二. 记忆化... 阅读全文
posted @ 2015-02-06 00:25 流白 阅读(15697) 评论(3) 推荐(5) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 下一页