Reverse Words in a given string-Asked in Goldman Sachs Interviews
Given a String S, reverse the string without reversing its individual words. Words are separated by dots.
The input consists of a single line containing a string ‘S’.
The output format contains a string which is the reversed version of the given string ‘S’.
Explanation of given Test Cases :
After reversing the whole string(not individual words), the input
string becomes much.very.program.this.like.i
- Initially, reverse the individual words of the given string one by one, for the above example, after reversing individual words the string should be “i.ekil.siht.margorp.yrev.hcum”.
- Reverse the whole string from start to end to get the desired output “much.very.program.this.like.i” in the above example.