Possible Duplicate:
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it
For example if i give a input as “This is a string”
I should get the output as “string a is This”
I cant get any idea on how to do it
First Reverse the string in place
Then Reverse each word in place (words are delimited by a space)