go: add «2486. Append Characters to String to Make Subsequence»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-06-03 15:29:18 +02:00
parent 79c92c471e
commit 5612db7232
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,14 @@
package append_characters_to_string_to_make_subsequence
func appendCharacters(s string, t string) int {
si, ti := 0, 0
for si < len(s) && ti < len(t) {
if s[si] == t[ti] {
ti++
}
si++
}
return len(t) - ti
}