Skip to content

Commit

Permalink
solve "68. Text Justification"
Browse files Browse the repository at this point in the history
  • Loading branch information
lancelote committed Sep 15, 2024
1 parent 9897966 commit 887a80c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .plan
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Sep 15, 2024

* re-solve "392. Is Subsequence"

Sep 14, 2024

re-solve question 28 using Knuth–Morris–Pratt
solve all "two pointers" questions in top-150
* solve "68. Text Justification"
* solve all "array / string" questions in top-150
Expand Down
18 changes: 8 additions & 10 deletions src/is_subsequence.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
n = len(s)
m = len(t)
si = 0
ti = 0

i1 = i2 = 0

while i1 < n and i2 < m:
if s[i1] == t[i2]:
i1 += 1
i2 += 1
while si < len(s) and ti < len(t):
if s[si] == t[ti]:
si += 1
ti += 1
else:
i2 += 1
ti += 1

return i1 == n
return si == len(s)

0 comments on commit 887a80c

Please sign in to comment.