Solution for removing duplicate chars from string