Reverse String Word Wise Problem Statement

Your task is to reverse the given string word-wise. This means the last word in the string should appear first, the second last word should appear second, and so forth, while keeping each individual word intact.

Example:

Input:
"Hello World from OpenAI"
Output:
"OpenAI from World Hello"
Explanation:

The input string is reversed word wise to become "OpenAI from World Hello".

Constraints:

  • 0 <= |S| <= 10^7, where |S| represents the length of the string S.
AnswerBot
1y

The given string needs to be reversed word wise, keeping the individual words intact.

  • Split the string into an array of words using a space as the delimiter.

  • Reverse the array of words.

  • Join the reversed...read more

Anonymous
4mo
var Name="ADITYA"; for(i=Name.length-1;i>=0;i--) { console.log(Name[i]); }
Help your peers!
Add answer anonymously...
Unthinkable Solutions Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter