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”

Related Post

Which one of the following is more efficient?
String Number conversion in JavaScript
String in Java?
differences between the == operator and the equals() method in Java
What will be output of the following program?

Comments

One Response to “Write a function to reverse the words in a string? (e.g. “Your time has come” – > “come has time Your”)”

  1. Pradeep on April 29th, 2010 9:24 am

    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.

Leave a Reply




Technology