nuxy / leetcode-151

Benchmark created on


Description

Reverse Words in a String

Setup

const reverseWords = function(s) {
  let words = s.split(/\s+/);
  words = words.reverse();
  return words.join(' ').trim();
};

Test runner

Ready to run.

Testing in
TestOps/sec
Test 1
reverseWords('the sky is blue'); // blue is sky the
ready
Test 2
reverseWords('  hello world  '); // world hello
ready
Test 3
reverseWords('a good   example'); // example good a
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.