Skip to content

Commit 9b80f0e

Browse files
add skeleton for 1062
1 parent c0a1c09 commit 9b80f0e

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ _If you like this project, please leave me a star._ ★
6767
|1078|[Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1078.java) | |Easy||
6868
|1071|[Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1071.java) | |Easy||
6969
|1065|[Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1065.java) | |Medium||
70+
|1062|[Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1062.java) | |Medium||
7071
|1056|[Confusing Number](https://leetcode.com/problems/confusing-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1056.java) | |Easy||
7172
|1055|[Fixed Point](https://leetcode.com/problems/fixed-point/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1055.java) | |Easy||
7273
|1051|[Height Checker](https://leetcode.com/problems/height-checker/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1051.java) | |Easy||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.fishercoder.solutions;
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+
public class _1062 {
33+
public static class Solution1 {
34+
public int longestRepeatingSubstring(String S) {
35+
//TODO: implement it
36+
return 0;
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.solutions._1062;
4+
import org.junit.BeforeClass;
5+
import org.junit.Ignore;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.assertEquals;
9+
10+
@Ignore
11+
public class _1062Test {
12+
private static _1062.Solution1 solution1;
13+
14+
@BeforeClass
15+
public static void setup() {
16+
solution1 = new _1062.Solution1();
17+
}
18+
19+
@Test
20+
public void test1() {
21+
assertEquals(0, (solution1.longestRepeatingSubstring("abcd")));
22+
}
23+
24+
@Test
25+
public void test2() {
26+
assertEquals(2, (solution1.longestRepeatingSubstring("abbaba")));
27+
}
28+
29+
@Test
30+
public void test3() {
31+
assertEquals(3, (solution1.longestRepeatingSubstring("aabcaabdaab")));
32+
}
33+
34+
@Test
35+
public void test4() {
36+
assertEquals(4, (solution1.longestRepeatingSubstring("aaaaa")));
37+
}
38+
39+
@Test
40+
public void test5() {
41+
assertEquals(10, (solution1.longestRepeatingSubstring("aaabaabbbaaabaabbaabbbabbbaaaabbaaaaaabbbaabbbbbbbbbaaaabbabbaba")));
42+
}
43+
}

0 commit comments

Comments
 (0)