Reverse Words in a String
Medium · Arrays & Strings · about 10 minutes
Asked at Meta, Microsoft, Google, Amazon, Apple.
Split s into words (a word is a maximal run of non-space characters) and return them back to front, joined by exactly one space. The output must have no spaces at either end, however many spaces s has.