Skip to content

Commit 32a8fda

Browse files
authored
Create 3330. Find the Original Typed String I (#830)
2 parents 83f3bd9 + 4875d6b commit 32a8fda

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
int possibleStringCount(string word) {
4+
int count = 1;
5+
int result = 0;
6+
7+
for (int i = 1; i < word.size(); i++) {
8+
if (word[i] == word[i - 1]) {
9+
count++;
10+
} else {
11+
result += (count - 1);
12+
count = 1;
13+
}
14+
}
15+
16+
result += (count - 1);
17+
return result + 1;
18+
}
19+
};

0 commit comments

Comments
 (0)