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

Explain the Skimming concept in PEGA for PEGA CSSA?

3 Ways to Run a Detached Command

DeltaHub Capital Investment In Ruby Protocol

Exporting SiteScope metrics into InfluxDB — Overview of the Solution

Master Go with functions

GitHub Actions to guard your workflow

tudaBirds introduces birdTris: Retro play #gamefi

What is the order of execution in salesforce?

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

One Mile on the globe Puzzle

LeetCode 146. LRU Cache

Interview Question 9— Top Interview Question

Leetcode 290. Word Pattern