1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/go/is-subsequence.go
Matej Focko 0d1683fb1d
go: add «392. Is Subsequence»
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-08-12 20:48:41 +02:00

18 lines
211 B
Go

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
}