Skip to content

Commit

Permalink
Time: 1 ms (80.21%), Space: 2.2 MB (49.74%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Sep 27, 2024
1 parent bd9e5f9 commit 5d7a65b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions 0392-is-subsequence/0392-is-subsequence.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
func isSubsequence(s string, t string) bool {
sIndex := 0
for i := 0; i < len(t); i++ {
if sIndex == len(s) {
idx := 0
for i := 0; i < len(t); i ++ {
if idx == len(s) {
return true
}

if t[i] == s[sIndex] {
sIndex ++
if s[idx] == t[i] {
idx ++
}
}

return sIndex == len(s)
return idx == len(s)
}

0 comments on commit 5d7a65b

Please sign in to comment.