feat(392-is-subsequence): simplify and add golang soln

This commit is contained in:
2022-02-19 19:58:35 +05:30
parent 106aac6492
commit 63397e07cd
2 changed files with 26 additions and 26 deletions

View File

@@ -0,0 +1,21 @@
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
}