mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
17 lines
270 B
Go
17 lines
270 B
Go
|
package util
|
||
|
|
||
|
import "unicode/utf8"
|
||
|
|
||
|
func HasSubseq(s, t string) bool {
|
||
|
i, j := 0, 0
|
||
|
for i < len(s) && j < len(t) {
|
||
|
s0, di := utf8.DecodeRuneInString(s[i:])
|
||
|
t0, dj := utf8.DecodeRuneInString(t[j:])
|
||
|
i += di
|
||
|
if s0 == t0 {
|
||
|
j += dj
|
||
|
}
|
||
|
}
|
||
|
return j == len(t)
|
||
|
}
|