计算字符串中行中子字符串出现的次数

时间:2018-04-12 18:30:26

标签: java string algorithm substring

我希望能够找到子串发生的最大次数连续,此子字符串尚未预定义,但它可以是任何内容。

req.body

例如,输入public static int countWordsOccurence(String line){ //return the occurence } 会返回 3 ,因为连续发生了3次

输入"raacdrunrunruntryingtotrackrunrun"的另一个示例也会返回 3 ,因为错误连续发生3次

注意:这与Occurrences of substring in a string不同,因为你没有得到你正在寻找的子串的输入,也没有计算出现的次数,而只是最多的次数它发生在一行。

0 个答案:

没有答案
相关问题