Write a function to reverse the words in a string? (e.g. “Your time has come” – > “come has time Your”)
This could be achieved by first writing a function to reverse the whole string. The output from this function will be.. “emoc sah emit ruoY”. Now we need to call same function for each individual word. So the final output will be “come has time Your”
February 9, 2008 | Filed Under Algorithm
Related Post
Comments
One Response to “Write a function to reverse the words in a string? (e.g. “Your time has come” – > “come has time Your”)”
Leave a Reply
Reverse a whole word first and then try to reverse each word individually.
for example I am a good boy first cnvert it to
boy good a am I(mirror image)than reverse each word individually. yob doog a ma I.