go: add «392. Is Subsequence»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-08-12 20:48:41 +02:00
parent 4bf8cc35ee
commit 0d1683fb1d
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

18
go/is-subsequence.go Normal file
View file

@ -0,0 +1,18 @@
package main
func isSubsequence(s string, t string) bool {
length := len(s)
i := 0
for j := range t {
if i < length && t[j] == s[i] {
i++
}
if i >= length {
break
}
}
return i == length
}