go + 双指针
func solve( str string ) string { // write code here if len(str) == 0 { return "" } i, j := 0, len(str)-1 bs := []byte(str) for ; i< j; i, j = i+1, j-1 { bs[i], bs[j] = bs[j], bs[i] } return string(bs) }
go + 双指针
func solve( str string ) string { // write code here if len(str) == 0 { return "" } i, j := 0, len(str)-1 bs := []byte(str) for ; i< j; i, j = i+1, j-1 { bs[i], bs[j] = bs[j], bs[i] } return string(bs) }