![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
递归
i-Blue
抱平常心走平常路
展开
-
poj 1579 递归-记忆化搜索
直接递归会重复计算一些值,如题所述会花费很长时间。最好的方法就是用记忆化搜索,用数组将值记录下来,当搜到已经计算过的值时直接使用就行了,避免再一次递归计算,这样会节省很多时间。代码如下:http://blog.csdn.net/non_cease/article/details/6817914#include using namespace std;const int size =转载 2016-04-18 11:13:28 · 395 阅读 · 0 评论 -
POJ 3295 Tautology(递归、构造)
#include#include#includeusing namespace std;vector stack; //0代表false 1代表true.string s;int judge(int index, int val){ int len = stack.size(); if (index < 0) { int out = 1; for (int k =原创 2016-04-19 23:02:54 · 326 阅读 · 0 评论 -
10. Regular Expression Matching-动态规划/递归回溯
mplement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input str原创 2016-09-11 21:40:08 · 1111 阅读 · 0 评论 -
最大子序列和问题的解_
问题:有数n1,n2,......,ns。求一个连续的子序列,这个序列的和最大。这个问题有O(n^3)、O(n^2)、O(n*lgn)以及O(n)时间复杂度的解法。下面主要说下O(n*lgn)和O(n)的解法。原创 2016-12-14 19:47:43 · 487 阅读 · 0 评论