SmartThings Interview Question

Reverse a string preserving space positions