摘要:
算法笔记 欧几里得算法求最大公约数 ~又称辗转相除法,求两数的最大公约数 gcd(a,b) = gcd(b,a%b) 一般代码递归形式 int gcd(int a,int b) { return b? gcd(b,a%b) :a ; } 迭代形式 int gcd(int a,int b) { whi 阅读全文
摘要:
KMP KMP-字符串匹配算法,pat模式串,长度为M; txt文本串,长度为N。KMP算法是在txt中查找子串pat,如果存在,返回起始索引,否则返回-1 。 https://zhuanlan.zhihu.com/p/83334559这个知乎专栏讲得很好 根据上面的理解 1、如果是暴力枚举的话,就 阅读全文