mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Add JS correct reverse method
This commit is contained in:
@ -190,13 +190,13 @@ javaScript:
|
||||
* @return {void} Do not return anything, modify s in-place instead.
|
||||
*/
|
||||
var reverseString = function(s) {
|
||||
return s.reverse();
|
||||
//Do not return anything, modify s in-place instead.
|
||||
reverse(s)
|
||||
};
|
||||
|
||||
var reverseString = function(s) {
|
||||
var reverse = function(s) {
|
||||
let l = -1, r = s.length;
|
||||
while(++l < --r) [s[l], s[r]] = [s[r], s[l]];
|
||||
return s;
|
||||
};
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user