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

Commit79cb61c

Browse files
add 1446
1 parent078e283 commit79cb61c

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1446|[Consecutive Characters](https://leetcode.com/problems/consecutive-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1446.java)||Easy|String|
1112
|1441|[Build an Array With Stack Operations](https://leetcode.com/problems/build-an-array-with-stack-operations/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1441.java)||Easy|Stack|
1213
|1437|[Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1437.java)||Medium|Array|
1314
|1436|[Destination City](https://leetcode.com/problems/destination-city/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1436.java)||Easy|String|
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1446 {
4+
publicstaticclassSolution1 {
5+
publicintmaxPower(Strings) {
6+
intmax =0;
7+
for (inti =0;i <s.length();i++) {
8+
intstart =i;
9+
while (i +1 <s.length() &&s.charAt(i) ==s.charAt(i +1)) {
10+
i++;
11+
}
12+
max =Math.max(max,i -start +1);
13+
}
14+
returnmax;
15+
}
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._1446;
4+
importorg.junit.BeforeClass;
5+
importorg.junit.Test;
6+
7+
importstaticjunit.framework.TestCase.assertEquals;
8+
9+
publicclass_1446Test {
10+
privatestatic_1446.Solution1solution1;
11+
12+
@BeforeClass
13+
publicstaticvoidsetup() {
14+
solution1 =new_1446.Solution1();
15+
}
16+
17+
@Test
18+
publicvoidtest1() {
19+
assertEquals(2,solution1.maxPower("leetcode"));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp