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
Traverse from the end, skip trailing spaces, then count contiguous non-space characters.
The last word is exactly the first non-space segment encountered from the end.
Updated Feb 2026