Skip to content

Commit 7b0aad4

Browse files
add 3083
1 parent edb9008 commit 7b0aad4

File tree

3 files changed

+41
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+41
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
| 3110 | [Score of a String](https://leetcode.com/problems/score-of-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3110.java) | | Easy |
3636
| 3095 | [Shortest Subarray With OR at Least K I](https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3095.java) | | Easy |
3737
| 3090 | [Maximum Length Substring With Two Occurrences](https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3090.java) | | Easy |
38+
| 3083 | [Existence of a Substring in a String and Its Reverse](https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3083.java) | | Easy |
3839
| 3074 | [Apple Redistribution into Boxes](https://leetcode.com/problems/apple-redistribution-into-boxes/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3074.java) | | Easy |
3940
| 3062 | [Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3062.java) | | Easy |
4041
| 3046 | [Split the Array](https://leetcode.com/problems/split-the-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3046.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3083 {
4+
public static class Solution1 {
5+
public boolean isSubstringPresent(String s) {
6+
StringBuilder sb = new StringBuilder();
7+
for (int i = 0; i < s.length() - 1; i++) {
8+
sb.append(s.charAt(i + 1));
9+
sb.append(s.charAt(i));
10+
if (s.indexOf(sb.toString()) != -1) {
11+
return true;
12+
}
13+
sb.setLength(0);
14+
}
15+
return false;
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.fourththousand;
2+
3+
import com.fishercoder.solutions.fourththousand._3083;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
9+
public class _3083Test {
10+
private static _3083.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _3083.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertTrue(solution1.isSubstringPresent("leetcode"));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)