Solution to Reverse Words in a String

In both
C++ (40+ ms)
and
Java (400+ ms)

They are accepted solutions but I am not sure if they are good enough