# Find the longest recurring substring [duplicate]

This question already has an answer here:

Given a string of no more than 255 characters, find a function that returns the longest recurring substring. An example would be:

aabbacadeauaaabba

where the longest recurring sub-string is aabba. I would preffer the answer in C/C++ as they are the only languages I know. The algorithm should be as fast as possible.

## marked as duplicate by Martin Ender, Jakube, Timtech, Peter Taylor, ProgramFOXFeb 6 '15 at 13:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• What is recurring string ? same characters ? Why is there a C++ language limitation ? – Optimizer Feb 6 '15 at 11:34
• I know only C/C++, sorry, substring not string, a recurring substring is a substring that appears more than once. – Sherpinsky Feb 6 '15 at 11:36
• Ah. It would probably be better to give out some examples. Also, this is PPCG so you need to have a winning criteria . Do you want the shortest code ? faster algorithm ? most popular code ? Also, language specific questions are frowned upon here, so it would be better if you can remove that restriction and just ask in the question that you are specifically looking for C++ answer – Optimizer Feb 6 '15 at 11:42
• Winning criteria please :) – Optimizer Feb 6 '15 at 11:45
• Are overlapping occurrences counted as distinct? For example, in the string aabbaabba, is the substring aabba recurring? – Zgarb Feb 6 '15 at 11:53