From b487e40bd7018dab2b1ae0a407e8d9b21165a076 Mon Sep 17 00:00:00 2001 From: "go-interview-practice-bot[bot]" <230190823+go-interview-practice-bot[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 13:32:30 +0000 Subject: [PATCH] Add solution for Challenge 2 --- .../submissions/kiramux/solution-template.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 challenge-2/submissions/kiramux/solution-template.go diff --git a/challenge-2/submissions/kiramux/solution-template.go b/challenge-2/submissions/kiramux/solution-template.go new file mode 100644 index 00000000..db5291d7 --- /dev/null +++ b/challenge-2/submissions/kiramux/solution-template.go @@ -0,0 +1,37 @@ +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 { + if len(s) == 0 { + return "" + } + str := []byte(s) + left := 0 + right := len(str) - 1 + for left < right { + str[left], str[right] = str[right], str[left] + left++ + right-- + } + return string(str) +}