The test doesn't seem to be valid to me. Explaining below the reason.
The problem statement says - "Given an input string, reverse the string word by word." For them, string means "multiple words separated by space". Now, see the NOTE section. It says "A word is defined as a sequence of non-space characters."
The intent of the problem is to reverse each word present in the string. And the string contains multiple words. Here, you are testing it on only single word "god".
Correct input would be
Input - "god is kind"
Output - "kind is god"
Also, you would observe we are not reversing characters present in word. We are reversing the complete string.
Thanks for the clarification.After I converted the string into list,I was able to reverse it.Any suggestions for good books/links to start Datastructures& A for beginners?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The test doesn't seem to be valid to me. Explaining below the reason.
The problem statement says - "Given an input string, reverse the string word by word." For them, string means "multiple words separated by space". Now, see the NOTE section. It says "A word is defined as a sequence of non-space characters."
The intent of the problem is to reverse each word present in the string. And the string contains multiple words. Here, you are testing it on only single word "god".
Correct input would be
Input - "god is kind"
Output - "kind is god"
Also, you would observe we are not reversing characters present in word. We are reversing the complete string.
I hope I have made it clear.
Thanks for the clarification.After I converted the string into list,I was able to reverse it.Any suggestions for good books/links to start Datastructures& A for beginners?