Exercises/#16 Reverse Words in a String
#16

Reverse Words in a String

MediumπŸ”€ Strings
60 XP

Problem

Given a string s, reverse the order of words. A word is a sequence of non-space characters. Remove extra spaces.

Examples

Input: s = 'the sky is blue'
Output: 'blue is sky the'

Input: s = '  hello world  '
Output: 'world hello'
stringtwo-pointer
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

16 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features