Skip to content

Commit f95ae71

Browse files
committed
Added Consecutive Characters.java
1 parent 1d52a20 commit f95ae71

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Easy/Consecutive Characters.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int maxPower(String s) {
3+
int count = 0;
4+
int idx = 0;
5+
int n = s.length();
6+
while (idx < n) {
7+
char c = s.charAt(idx);
8+
int tempCount = 0;
9+
while (idx < n && s.charAt(idx) == c) {
10+
idx++;
11+
tempCount++;
12+
}
13+
count = Math.max(count, tempCount);
14+
}
15+
return count;
16+
}
17+
}

0 commit comments

Comments
 (0)