Pregunta de entrevista de Levrx

Given a sentence as a String, reverse it. Write code that can differentiate spaces, leading or trailing.