Given a string **s**, reverse the order of the words in the string while keeping the individual words unchanged. Words are separated by spaces. Note: The output string should have words separated by a **single space**, with **no extra spaces** at the beginning or end.
Topics
Companies
Articles
Examples:
Expected Time Complexity: O(n)
Expected Space Complexity: O(n)
Constraints:
1 <= s.size() <= 10^6
String s contains only lowercase English alphabets and spaces.
Companies:
AmazonMicrosoftAdobeGoldman SachsCisco + 1 more
Topics:
String
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.