Medium · Tries
Longest repeated substring
Given a string str, return its longest substring that occurs at least twice (the two occurrences may overlap), or "" if no substring repeats; when several repeated substrings share the maximum length, any one of them is accepted.
Examples
Example 1
{
"str": "abab"
}Output: "ab"
Example 2
{
"str": "banana"
}Output: "ana"
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.