Skip to content
← Back to Community
5.4. Strings: Swap two words
Profile icon
pole55

"Given a string consisting of exactly two words separated by a space. Print a new string with the first and second words swapped: the second word is printed first. Consider all adjacent non-space characters a single word.

Can you solve it without using if-else and loops?"

Voters
Profile icon
lamausman
Profile icon
SK10IW
Profile icon
SARAZANICHELLI
Profile icon
LorenKhatib
Profile icon
tedcoop
Profile icon
Lohloh531
Profile icon
nogamenoken
Profile icon
tomsfy
Profile icon
2D31Liam2D31
Profile icon
prdpgautam