Skip to content

Commit 1dac1f2

Browse files
authored
Create Find the Original Typed String I.py
1 parent ea5a475 commit 1dac1f2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Find the Original Typed String I.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
Alice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a character being typed multiple times.
3+
4+
Although Alice tried to focus on her typing, she is aware that she may still have done this at most once.
5+
6+
You are given a string word, which represents the final output displayed on Alice's screen.
7+
8+
Return the total number of possible original strings that Alice might have intended to type.
9+
'''
10+
11+
class Solution:
12+
def possibleStringCount(self, word: str) -> int:
13+
c = 1
14+
15+
for i in range(len(word)-1):
16+
cur = word[i]
17+
next = word[i+1]
18+
if cur == next:
19+
c+=1
20+
return c

0 commit comments

Comments
 (0)