In today’s coding exercise the task is to reverse the words in a string, where words are separated by one or more spaces.
Summary
Build a program that reverses the words in a string, where words are separated by one or more spaces.
Exercise File
Exercise Description
Given the following strings:
"dog lazy the over jumped fox brown quick The"
Write a program that reverses the order of the words.
Sample Input
"dog lazy the over jumped fox brown quick The"
Sample Output
"The quick brown fox jumped over the lazy dog"
Real World Usage
This is a very common Ruby coding interview question since it tests knowledge of how to works with strings, arrays, and how they can work together.
Solution
Can be found on the solutions branch on github.