我通过使用正则表达式在String中找到重复的String来编写以下Java s。现在,我尝试找到它的复杂性,如果有人知道它的复杂性,请告诉我。
String s = "ABCABCAAAABBBBCCAAABCGABCABC";
Pattern pattern = Pattern.compile("(?:([ABC])(?!\\1)([ABC])\\1\\2)+");
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
System.out.print("FOUND");
}
Run Code Online (Sandbox Code Playgroud)