求出在字符串中连续出现最多的子串是什么和出现的次数(JAVA实现)

今天看到这样一个题:

请统计出以下这段文字中,出现频率最高的二元字符(两个字符)的组合。

(举例:在字符串“1252336528952”中,二元字符组合“52”出现3次,频率最高。)

oneofthecentralresultsofairesearchinthe1970swasthattoachievegoodperformanceaisystemsmusthav
elargeamountsofknowledgeknowledgeispowertheslogangoeshumansclearlyusevastamountsofknowledge
andifaiistoachieveitslongtermgoalsaisystemsmustalsousevastamountssincehandcodinglargeamount
sofknowledgeintoasystemisslowtediousanderrorpronemachinelearningtechniqueshavebeendeveloped
toautomaticallyacquireknowledgeoftenintheformofifthenrulesproductionsunfortunatelythishasof
tenledtoautilityproblemminton1988bthelearninghascausedanoverallslowdowninthesystemforexampl
einmanysystemslearnedrulesareusedtoreducethenumberofbasicstepsthesystemtakesinordertosolvep
roblemsbypruningthesystemssearchspaceforinstancebutinordertodetermineateachstepwhichrulesar
eapplicablethesystemmustmatchthemagainstitscurrentsituationusingcurrenttechniquesthematcher
slowsdownasmoreandmorerulesareacquiredsoeachsteptakeslongerandlongerthisectcanoutweighthere
ductioninthenumberofstepstakensothatthenetresultisaslowdownthishasbeenobservedinseveralrece
ntsystemsminton1988aetzioni1990tambeetal1990cohen1990ofcoursetheproblemofslowdownfromincrea
singmatchcostisnotrestrictedtosystemsinwhichthepurposeofrulesistoreducethenumberofproblemso
lvingstepsasystemacquiringnewrulesforanypurposecanslowdowniftherulessignicantlyincreasethem
atchcostandintuitivelyoneexpectsthatthemoreproductionsthereareinasystemthehigherthetotalmat
chcostwillbethethesisofthisresearchisthatwecansolvethisprobleminabroadclassofsystemsbyimpro
vingthematchalgorithmtheyuseinessenceouraimistoenablethescalingupofthenumberofrulesinproduc
tionsystemsweadvancethestateoftheartinproductionmatchalgorithmsdevelopinganimprovedmatchalg
orithmwhoseperformancescaleswellonasignicantlybroaderclassofsystemsthanexistingalgorithmsfu
rthermorewedemonstratethatbyusingthisimprovedmatchalgorithmwecanreduceoravoidtheutilityprob
leminalargeclassofmachinelearningsystems

我觉的这道题很有意思,以前写过c语言的实现,现在用java来解决这个问题,直接看代码:

package com.company;

import java.io.*;
import java.util.*;
import java.util.List;

/**
 * * @projectName test
 * * @title Test3
 * * @package com.company
 * * @description  查找字符串中出现最多的子类
 * * @author IT_CREAT
 * * @date  2020 2020/5/24/024 22:32  
 * * @version 1.0.0
 */
public class Test3 {

    /**
     * 待测试的字符串
     */
    public static String testTtr = "oneofthecentralresultsofairesearchinthe1970swasthattoachievegoodper" +
            "formanceaisystemsmusthavelargeamountsofknowledgeknowledgeispowertheslogangoeshumansclearly" +
            "usevastamountsofknowledgeandifaiistoachieveitslongtermgoalsaisy
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值