SmartThings interview question

Reverse a string preserving space positions