diff --git a/challenge-2/submissions/Sairaviteja27/solution-template.go b/challenge-2/submissions/Sairaviteja27/solution-template.go new file mode 100644 index 00000000..df87786a --- /dev/null +++ b/challenge-2/submissions/Sairaviteja27/solution-template.go @@ -0,0 +1,33 @@ +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 { + // Convert the string to a slice of runes to handle Unicode characters correctly + runes := []rune(s) + n := len(runes) + for i := 0; i < n/2; i++ { + // Swap the ith element with its mirror position + runes[i], runes[n-1-i] = runes[n-1-i], runes[i] + } + return string(runes) +}