Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def isLongPressedName(self, name: str, typed: str) -> bool:
- p1 = 0
- p2 = 0
- while p2 < len(typed):
- if p1 < len(name) and name[p1] == typed[p2]:
- p1 += 1
- p2 += 1
- elif p1 and name[p1-1] == typed[p2]:
- p2 += 1
- else:
- return False
- if p1 == len(name) and p2 == len(typed):
- return True
- else:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement