Simple Go solution


  • 0
    B

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


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.