Skip to content

Reverse the word order

Reverse the word order

Given a sentence of space-separated words, return the words in reverse order: the quick brownbrown quick the. Split on spaces with s.split(" "), then build the result from the last word to the first. A StringBuilder is the tidy way to join them.

Log in or create account

IGCSE & A-Level