Solution to Reverse Words in a String by LeetCode

27 Jul

Question: https://oj.leetcode.com/problems/reverse-words-in-a-string/

Question Name: Reverse Words in a String

To solve it with Python, it is as simple as one statement.

But is there a better way? Anyone, who read the excellent book Programming Pearls before, might remember Doug McIlroy’s Handwaving. Because Python’s string is immutable, I have to implement it with C++.

PS: this is my first time to write C++ code under Mac system. It seems that the gcc is not working. I have to use the following command to compile it:
clang++ -std=c++11 -stdlib=libc++ -lc++abi ReverseWordsinaString.cpp

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!