Dsa
Strings
Warm-up
Reverse String Segments
Create a function that reverses the segments of a string separated by spaces. The input will be a single line string. The output should be the original string with the order of the segments reversed.
Example input:
hello there
Example output:
there hello
Key concepts
stringsreversalsegments
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now