Skip to content

Commit c504451

Browse files
committed
925
1 parent 3f8e5df commit c504451

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

code/925.long-pressed-name.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# @lc app=leetcode id=925 lang=python3
3+
#
4+
# [925] Long Pressed Name
5+
#
6+
7+
# @lc code=start
8+
class Solution:
9+
def isLongPressedName(self, name: str, typed: str) -> bool:
10+
m = len(name)
11+
n = len(typed)
12+
13+
i, j = 0, 0
14+
while j < n:
15+
if (i < m) and (name[i] == typed[j]):
16+
i += 1
17+
j += 1
18+
else:
19+
if (j > 0) and (typed[j] == typed[j - 1]):
20+
j += 1
21+
else:
22+
return False
23+
return i == m
24+

0 commit comments

Comments
 (0)