Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Scan from the end of the string. Skip spaces, then capture each word boundary and append it to a result list. Join captured words with single spaces.
Reading words from right to left directly builds reversed word order without an extra full reverse step.
Updated Feb 2026