Pregunta de entrevista de Boolmind

Write a function that determines if a given string is a valid palindrome, ignoring spaces, punctuation, and case. Can you optimize it for large inputs?