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

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy