Thanks to visit codestin.com
Credit goes to www.educative.io

...

/

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”.

Codestin Search App Codestin Search App Hello World Codestin Search App World Hello Codestin Search App

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

Codestin Search App Codestin Search App The quick brown fox jumped over the lazy dog. Codestin Search App dog. lazy the over jumped fox brown quick The Codestin Search App

Sample input

"Hello world."

Expected output

"world. Hello"

...