Space Replacement(LintCode 212):

Problem