go: add «2486. Append Characters to String to Make Subsequence»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
79c92c471e
commit
5612db7232
1 changed files with 14 additions and 0 deletions
14
go/append-characters-to-string-to-make-subsequence.go
Normal file
14
go/append-characters-to-string-to-make-subsequence.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in a new issue