Advertisement
serega1112

925

Dec 13th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. class Solution:
  2.     def isLongPressedName(self, name: str, typed: str) -> bool:
  3.         p1 = 0
  4.         p2 = 0
  5.        
  6.         while p2 < len(typed):
  7.             if p1 < len(name) and name[p1] == typed[p2]:
  8.                 p1 += 1
  9.                 p2 += 1
  10.             elif p1 and name[p1-1] == typed[p2]:
  11.                 p2 += 1
  12.             else:
  13.                 return False
  14.            
  15.         if p1 == len(name) and p2 == len(typed):
  16.             return True
  17.         else:
  18.             return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement