Write a function to retrieve t | CareerCup
Write a function to retrieve the number of a occurrences of a substring(even the reverse of a substring) in a string without using the java substring() method. Ex: 'dc' in 'abcd' occurs 2 times (dc, cd).
Read full article from Write a function to retrieve t | CareerCupIn an interview setting , use rabin karp.解法:按照这种算法,应该是原模式串匹配一次,反转模式串再匹配一次,然后结果加起来乘以二。如果模式串本身是回文串的话,那就只匹配一次。匹配使用KMP算法。