Swap first and last words in a sentence.: Medium Programming Problem