Amazon interview question

Given a string, remove redundant spaces.