1062. Longest Repeating Substring π
Description
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.
Example 3:
Input: s = "aabcaabdaab" Output: 3 Explanation: The longest repeating substring is "aab", which occurs 3 times.
Constraints:
1 <= s.length <= 2000
s
consists of lowercase English letters.
Solutions
Solution 1
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|