Skip to content

Instantly share code, notes, and snippets.

@mtzfox
Created July 12, 2023 05:46
Show Gist options
  • Save mtzfox/6a031f06a1d1f33ea42dd83eeb7d7a84 to your computer and use it in GitHub Desktop.
Save mtzfox/6a031f06a1d1f33ea42dd83eeb7d7a84 to your computer and use it in GitHub Desktop.
Runtime:45 ms, Beats: 99.44%
var reverseWords = function (s) {
let strArr = s
.replace(/\s{2,}/g, ' ')
.trim()
.split(' ')
.reverse();
return strArr.join(' ');
};
@mtzfox
Copy link
Author

mtzfox commented Jul 12, 2023

From Leetcode

Runtime:45 ms, Beats: 99.44%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment