go 刷算法第一题——反转字符串
package main
/**
* 反转字符串
* @param str string字符串
* @return string字符串
*/
func solve( str string ) string {
// write code here
if len(str) == 0 {
return ""
}
runes := []rune(str)
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)
}