443. Longest Repeating Substring

Given a string s, return the length of the longest repeating substrings.

If no repeating substring exists, return 0.

Example 1:

Input: s = "abcd"

Output: 0

Explanation:

There is no repeating substring.

Example 2:

Input: s = "abbaba"

Output: 2

Explanation:

The longest repeating substrings are "ab" and "ba", each of which occurs twice.

Now Your Turn!

Pick the correct output for the given input

Input: s = "aabcaabdaab"

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= s.length <= 2000
  • s consists of lowercase English letters.

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
int longestRepeatingSubstring(string s) {
// Your code goes here
}
};
Test Case

Input:

S