From 82f4a61dd149c95bc421d7a17ae34f486ce9e3a2 Mon Sep 17 00:00:00 2001 From: "go-interview-practice-bot[bot]" <230190823+go-interview-practice-bot[bot]@users.noreply.github.com> Date: Sat, 6 Dec 2025 11:17:14 +0000 Subject: [PATCH] Add solution for Challenge 2 --- .../DaniilYuz/solution-template.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 challenge-2/submissions/DaniilYuz/solution-template.go diff --git a/challenge-2/submissions/DaniilYuz/solution-template.go b/challenge-2/submissions/DaniilYuz/solution-template.go new file mode 100644 index 00000000..5ff4759b --- /dev/null +++ b/challenge-2/submissions/DaniilYuz/solution-template.go @@ -0,0 +1,30 @@ +package main + +import ( + "bufio" + "fmt" + "os" +) + +func main() { + // Read input from standard input + scanner := bufio.NewScanner(os.Stdin) + if scanner.Scan() { + input := scanner.Text() + + // Call the ReverseString function + output := ReverseString(input) + + // Print the result + fmt.Println(output) + } +} + +// ReverseString returns the reversed string of s. +func ReverseString(s string) string { + res := []byte(s) + for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 { + res[i], res[j] = res[j], res[i] + } + return string(res) +}