Skip to content

Latest commit

 

History

History

reverse-words-in-string

Reverse Words in a String

Given an input string, reverse all the words. To clarify, input: "Interviews are awesome!" output: "awesome! are Interviews". Consider all consecutive non-whitespace characters as individual words. If there are multiple spaces between words reduce them to a single white space. Also remove all leading and trailing whitespaces. So, the output for " CS degree", "CS degree", "CS degree ", or " CS degree " are all the same: "degree CS".

Source

http://www.ardendertat.com/2011/10/31/programming-interview-questions-12-reverse-words-in-a-string/