925

Posted on 2020-10-21 22:53  黑炽  阅读(134)  评论(0编辑  收藏  举报
 1 class Solution(object):
 2     def isLongPressedName(self, name, typed):
 3         """
 4         :type name: str
 5         :type typed: str
 6         :rtype: bool
 7         """
 8         i, j = 0, 0
 9         while j < len(typed):
10             if i < len(name) and name[i] == typed[j]:
11                 i += 1
12                 j += 1
13             elif  j > 0 and typed[j] == typed[j - 1]:#首字母相同的前提下,若type有重复的话
14                 j += 1
15             else:
16                 return False
17         
18         return i == len(name)