Reverse the Words (Set 12)

Easy

Given a sentence whose words are separated by single spaces, return the sentence with the word order reversed.

For example "hello there world" becomes "world there hello".

Reverse the Words (Set 12) — the data. This set runs 4 cases: sentence is a string of 93–97 characters. The hidden cases are the largest of the set.

Example 1

reverseWords()
Input
sentence = "mehlhbhahfllmmibdabaedcmljlpbjdfbakmhhcgdoioef tusyzrwzruvutwrtzwvxtxvuyswxxstyswzrrywsrzsxtr"
Output
"tusyzrwzruvutwrtzwvxtxvuyswxxstyswzrrywsrzsxtr mehlhbhahfllmmibdabaedcmljlpbjdfbakmhhcgdoioef"

Why

`reverseWords` returns `"tusyzrwzruvutwrtzwvxtxvuyswxxstyswzrrywsrzsxtr mehlhbhahfllmmibdabaedcmljlpbjdfbakmhhcgdoioef"` for this input.

Example 2

reverseWords()
Input
sentence = "dgambncihoilgmiejgaipeoldmhgpechppgdnkphkimefio tvxxzzssrzyrwzuwtrzyyxuuzvwxurwssrrvrtzryzxwzzut"
Output
"tvxxzzssrzyrwzuwtrzyyxuuzvwxurwssrrvrtzryzxwzzut dgambncihoilgmiejgaipeoldmhgpechppgdnkphkimefio"

Why

`reverseWords` returns `"tvxxzzssrzyrwzuwtrzyyxuuzvwxurwssrrvrtzryzxwzzut dgambncihoilgmiejgaipeoldmhgpechppgdnkphkimefio"` for this input.
Constraints
0 <= sentence.length <= 10^4
Words are separated by exactly one space.
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Strings

Implement reverseWords in the editor and return the answer — printing it is never graded.