mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
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