string reverseWords(string s) {
int i=0,n=s.size(),j;
string ans="";
string temp="";
while(i<s.size())
{
while(i<n && s[i]==' ')
{
i++;
}
j=i+1;
while(j<n && s[j]!=' ')
{
j++;
}
temp =s.substr(i,j-i);
if (!temp.empty()) {
if (ans.empty())
ans = temp;
else
ans = temp + " " + ans;
}
i=j+1;
}
return ans;
}