Rabin_Karp 哈希通过比较hash值是否相等来比较每个字符串是否相等有概率出错(很小)字符串x1,x2,x3……xk基底e;模数mo;hash=(xk*e^0+xk-1*e^1+......+x1*e^k-1)mod mo注意:①字符映射到数字不要映射到0②基底e>字符种类数③据说mo数为大素数出错概率小mo=1000000007(存int64)mo=666623333递推建hash:初始条件:hash[1]=x1;递推式:hash[i]=(hash[i-1]*e+xi)mod mo;区…
[LeetCode]647. Palindromic Substrings 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/palindromic-substrings/description/ 题目描述: Given a string, your task is to count how many palindromic substrings in this string. The substrings with dif…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 组合数 日期 题目地址:https://leetcode-cn.com/problems/count-substrings-with-only-one-distinct-letter/ 题目描述 Given a string S, return the number of substrings that have only one distinct l…
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the numbe…
1087: Common Substrings Time Limit:3000/1000 MS (Java/Others)   Memory Limit:163840/131072 KB (Java/Others)Total Submissions:857   Accepted:112 [Submit][Status][Discuss] Description You are given two long strings A and B. They are comprised of lowerc…
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative…
Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the…
原题链接在这里:https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters/ 题目: Given a string S, return the number of substrings of length K with no repeated characters. Example 1: Input: S = "havefunonleetcode", K = 5 Output: 6…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/unique-substrings-in-wraparound-string/description/ 题目描述: Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:暴力循环 方法二:固定起点向后找 方法三:动态规划 日期 题目地址:https://leetcode.com/problems/palindromic-substrings/description/ 题目描述 Given a string, your task is to count how many palindromic substrin…