Reverse Sentence, is a Strings related problem and in this post we will see how we can solve this challenge in C++

Given an input string, reverse the string word by word.


Given s = "the sky is blue",

return "blue is sky the". for reversing the word algo: 1.reverse the entire sentence 2.reverse the individual words first reverse the entire string then reverse the individual words find the starting index of a word and its ending index if it is space then skip it since the starting index of the word has been found , find the ending index next

Please check the main.cpp snippet for the solution.

This solution originally posted at: Github by @susantabiswas