力扣链接:
https://leetcode-cn.com/probl…
解题思路:
- 翻转字符串这道题比较简单,应用两个指针,而后从首位开始遍历,替换首尾地位,循环直到首尾相遇
func reverseString(s []byte) {n := len(s)
low, high := 0, n-1
for low <= high {s[low], s[high] = s[high], s[low]
low++
high--
}
}
力扣链接:
https://leetcode-cn.com/probl…
解题思路:
func reverseString(s []byte) {n := len(s)
low, high := 0, n-1
for low <= high {s[low], s[high] = s[high], s[low]
low++
high--
}
}