diff --git a/problems/0925.长按键入.md b/problems/0925.长按键入.md index 0ef5a3d7..7aab71a2 100644 --- a/problems/0925.长按键入.md +++ b/problems/0925.长按键入.md @@ -129,29 +129,21 @@ class Solution { ``` ### Python ```python -class Solution: - def isLongPressedName(self, name: str, typed: str) -> bool: - i, j = 0, 0 - m, n = len(name) , len(typed) - while i< m and j < n: - if name[i] == typed[j]: # 相同时向后匹配 - i += 1 - j += 1 - else: # 不相同 - if j == 0: return False # 如果第一位不相同,直接返回false - # 判断边界为n-1,若为n会越界,例如name:"kikcxmvzi" typed:"kiikcxxmmvvzzz" - while j < n - 1 and typed[j] == typed[j-1]: j += 1 - if name[i] == typed[j]: - i += 1 - j += 1 - else: return False - # 说明name没有匹配完 - if i < m: return False - # 说明type没有匹配完 - while j < n: - if typed[j] == typed[j-1]: j += 1 - else: return False - return True + i = j = 0 + while(i