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
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
If the string is How are you.
ReplyDelete1. Reverse the entire string
uoy era woh
Time Complexity of 1. is O(n)
2. Reverse the individual words again.
you are how.