Skip to content

Commit 0d68682

Browse files
authored
Create Find the Original Typed String I.java
1 parent 65583ae commit 0d68682

File tree

1 file changed

+17
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)