Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43e2da8

Browse files
add 1933
1 parent3d40976 commit43e2da8

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ _If you like this project, please leave me a star._ ★
5151
|1941|[Check if All Characters Have Equal Number of Occurrences](https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1941.java)||Easy||
5252
|1936|[Add Minimum Number of Rungs](https://leetcode.com/problems/add-minimum-number-of-rungs/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1936.java)||Medium||
5353
|1935|[Maximum Number of Words You Can Type](https://leetcode.com/problems/maximum-number-of-words-you-can-type/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1935.java)||Easy|String|
54+
|1933|[Check if String Is Decomposable Into Value-Equal Substrings](https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1933.java)||Easy|String|
5455
|1929|[Concatenation of Array](https://leetcode.com/problems/concatenation-of-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1929.java)||Easy||
5556
|1926|[Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1926.java)||Medium|DP, DFS, BFS|
5657
|1925|[Count Square Sum Triples](https://leetcode.com/problems/count-square-sum-triples/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1925.java)||Easy|Array, Greedy|
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1933 {
4+
publicstaticclassSolution1 {
5+
publicbooleanisDecomposable(Strings) {
6+
intlengthTwoCount =0;
7+
for (inti =0;i <s.length();i++) {
8+
intstart =i;
9+
charprev =s.charAt(start);
10+
while (i <s.length() &&s.charAt(i) ==prev) {
11+
i++;
12+
}
13+
if (i >=s.length()) {
14+
i--;
15+
}
16+
if (s.charAt(i) !=prev) {
17+
i--;
18+
}
19+
if ((i -start +1) %3 ==2) {
20+
lengthTwoCount++;
21+
}elseif ((i -start +1) %3 ==0) {
22+
continue;
23+
}else {
24+
returnfalse;
25+
}
26+
}
27+
returnlengthTwoCount ==1;
28+
}
29+
}
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._1933;
4+
importorg.junit.BeforeClass;
5+
importorg.junit.Test;
6+
7+
importstaticorg.junit.Assert.assertEquals;
8+
9+
publicclass_1933Test {
10+
privatestatic_1933.Solution1solution1;
11+
12+
@BeforeClass
13+
publicstaticvoidsetup() {
14+
solution1 =new_1933.Solution1();
15+
}
16+
17+
@Test
18+
publicvoidtest1() {
19+
assertEquals(false,solution1.isDecomposable("000111000"));
20+
}
21+
22+
@Test
23+
publicvoidtest2() {
24+
assertEquals(true,solution1.isDecomposable("00011111222"));
25+
}
26+
27+
@Test
28+
publicvoidtest3() {
29+
assertEquals(false,solution1.isDecomposable("011100022233"));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp