Skip to content

Commit 61c1296

Browse files
authored
Refactor isSubsequence method for clarity
1 parent fa8696e commit 61c1296

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

0392-is-subsequence/solution.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
class Solution:
22
def isSubsequence(self, s: str, t: str) -> bool:
3-
len_of_str = len(s)
43
i = 0
54

6-
for j in range(len(t)):
7-
if i < len_of_str and t[j] == s[i]:
5+
for char in t:
6+
if i < len(s) and s[i] == char:
87
i += 1
9-
10-
return i == len_of_str
8+
return i == len(s)
9+
1110

0 commit comments

Comments
 (0)