1062. Longest Repeating Substring

https://leetcode.com/problems/longest-repeating-substring

Description

Given a string s, find out the length of the longest repeating substring(s). Return 0 if no repeating substring exists.

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.

Example 3:

**Input:** s = "aabcaabdaab"
**Output:** 3
**Explanation:** The longest repeating substring is "aab", which occurs 3 times.

Example 4:

**Input:** s = "aaaaa"
**Output:** 4
**Explanation:** The longest repeating substring is "aaaa", which occurs twice.

Constraints:

  • The string s consists of only lowercase English letters from 'a' - 'z'.

  • 1 <= s.length <= 1500

ac

Last updated