...

/

Reverse Words in a Sentence

Reverse Words in a Sentence

Given a sentence (an array of characters), reverse the order of its words.

Statement

Given a sentence (an array of characters), reverse the order of its words without affecting the order of letters within a given word. All operations must be done in place.

Example

The “Hello World” string should be reversed as “World Hello”.

g a Hello World b World Hello a->b

Here’s another example of reversing words in a sentence:

g a The quick brown fox jumped over the lazy dog. b dog. lazy the over jumped fox brown quick The a->b

Sample input

"Hello world."

Expected output

"world. Hello"

... ...