leetcode/0392_is-subsequence/golang/main.go

22 lines
265 B
Go
Raw Permalink Normal View History

func isSubsequence(s string, t string) bool {
slen, tlen, si, ti := len(s), len(t), 0, 0
if slen == 0 {
return true
}
if slen > tlen {
return false
}
for ti < tlen && si < slen {
if s[si] == t[ti] {
si += 1
}
ti += 1
}
return si == slen
}