Levrx interview question

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