Saturday, October 22, 2011

Reverse a string, word by word

make it inplace

1 comment:

  1. If understand the question correctly, considering the post text as input - "make it inplace" should be transformed into "inplace it make".

    We can do it in two fold. Reverse the string by exchanging (1, n), (2, n-1), so on. Using space as delimiter, reverse each word of reversed string by exchange approach.

    Is there any other approach?