idiombook
8/5/2017 - 1:37 PM

[language: Go, example: NPLTraining - 00]

[language: Go, example: NPLTraining - 00]

package main

import (
  "fmt"
)

func main() {
    Solve()
}

func Solve() {
    target := "stressed"
    fmt.Println(Reverse(target))
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}