Reverse word's of a string in O(1) space.

Reverse the words of a string
Eg:: if string is GNU programs are the best
Output = best the are programs GNU

note :: You are not allowed to use extra space and do it in the best time complexity


  1. If the string is How are you.
    1. Reverse the entire string
    uoy era woh
    Time Complexity of 1. is O(n)

    2. Reverse the individual words again.
    you are how.


Post a Comment

Popular posts from this blog