Microsoft Interview Question

filtering out special characters in the string