Reverse Words in a given string-Asked in Goldman Sachs Interviews

Problem Statement:

Given a String S, reverse the string without reversing its individual words. Words are separated by dots.

Input Format

The input consists of a single line containing a string ‘S’.

Output Format:

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


  • 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 “” in the above example.


Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.




Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Lock Account after “x” amount of attempts — Spring Security

Faculty Dashboard

Initial Wizard Offering

How to add Conda to Git Bash (Windows)

*kwargs, *args

How not to interview

A beginner's guide to web development in 2022 in short, PART ONE.

RabbitMQ Queue with Docker in .NET

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Upskilling students for tech placements!

More from Medium

Sorted Insert for Circular Linked List

Oracle Interview Experience (On-Campus)

LeetCode 146. LRU Cache

Meta / Amazon / Google / Microsoft Interview Question: Wildcard Matching Solution | LeetCode-44…