From 5612db723279484da0e0a6757ded9aba8f5d6295 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 3 Jun 2024 15:29:18 +0200 Subject: [PATCH] =?UTF-8?q?go:=20add=20=C2=AB2486.=20Append=20Characters?= =?UTF-8?q?=20to=20String=20to=20Make=20Subsequence=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- ...end-characters-to-string-to-make-subsequence.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 go/append-characters-to-string-to-make-subsequence.go diff --git a/go/append-characters-to-string-to-make-subsequence.go b/go/append-characters-to-string-to-make-subsequence.go new file mode 100644 index 0000000..79ad4a1 --- /dev/null +++ b/go/append-characters-to-string-to-make-subsequence.go @@ -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 +}