Skip to content

Commit ab3dcee

Browse files
committed
925
1 parent 56768db commit ab3dcee

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

TP/925.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Long Pressed Name
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/long-pressed-name/discuss/183994/C%2B%2BJavaPython-Two-Pointers)
6+
7+
---
8+
9+
#### Solution
10+
11+
- 保持长的字符串滑动,短的字符串每次匹配,当去除掉重复的时候都不等就是False
12+
13+
---
14+
15+
#### Code
16+
17+
O(m+n)
18+
19+
```python
20+
class Solution:
21+
def isLongPressedName(self, name: str, typed: str) -> bool:
22+
i = 0
23+
for j in range(len(typed)):
24+
if i < len(name) and name[i] == typed[j]:
25+
i += 1
26+
elif j == 0 or typed[j] != typed[j - 1]:
27+
return False
28+
return i == len(name)
29+
```

0 commit comments

Comments
 (0)