Amazon Interview Question

Revert word sequences in a string