added the code to reverse the order of the words alone in linear time