|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1062. Longest Repeating Substring |
5 |
| - * |
6 |
| - * Given a string S, find out the length of the longest repeating substring(s). Return 0 if no repeating substring exists. |
7 |
| - * |
8 |
| - * Example 1: |
9 |
| - * Input: "abcd" |
10 |
| - * Output: 0 |
11 |
| - * Explanation: There is no repeating substring. |
12 |
| - * |
13 |
| - * Example 2: |
14 |
| - * Input: "abbaba" |
15 |
| - * Output: 2 |
16 |
| - * Explanation: The longest repeating substrings are "ab" and "ba", each of which occurs twice. |
17 |
| - * |
18 |
| - * Example 3: |
19 |
| - * Input: "aabcaabdaab" |
20 |
| - * Output: 3 |
21 |
| - * Explanation: The longest repeating substring is "aab", which occurs 3 times. |
22 |
| - * |
23 |
| - * Example 4: |
24 |
| - * Input: "aaaaa" |
25 |
| - * Output: 4 |
26 |
| - * Explanation: The longest repeating substring is "aaaa", which occurs twice. |
27 |
| - * |
28 |
| - * Note: |
29 |
| - * The string S consists of only lowercase English letters from 'a' - 'z'. |
30 |
| - * 1 <= S.length <= 1500 |
31 |
| - * */ |
32 | 3 | publicclass_1062 {
|
33 | 4 | publicstaticclassSolution1 {
|
34 | 5 | publicintlongestRepeatingSubstring(StringS) {
|
|