We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接
先明确题目要求:
不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。
const reverseString = function(s) { s.reverse() }
这道题可不是为了考察我们是否知道 reverse() 这个 API,我们来看不借助内置方法如何解题。
reverse()
const reverseString = function (s) { let left = 0, right = s.length - 1; while (left < right) { [s[left], s[right]] = [s[right], s[left]] left++ right-- } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接
先明确题目要求:
这道题可不是为了考察我们是否知道
reverse()
这个 API,我们来看不借助内置方法如何解题。双指针
The text was updated successfully, but these errors were encountered: