Given a string, determine if it is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.

Function Signature:

def is_valid_palindrome(s: str) -> bool:
    """
    Determine if the given string is a palindrome.

    Parameters:
    - s: Input string.

    Returns:
    - bool: True if the string is a palindrome, False otherwise.
    """
    # Your code here

Example:

# Input: "A man, a plan, a canal: Panama"
# Output: True
# Explanation: The string reads the same forward and backward after ignoring spaces, punctuation, and capitalization.

# Input: "AbcbA"
# Output: True

# Input: ""
# Output: True

# Input: "race a car"
# Output: False
# Explanation: The string does not read the same forward and backward.

Note:

  • You may assume the string contains only printable ASCII characters.

Instructions:

  • Write the is_valid_palindrome function to solve the problem.
  • Implement your solution in Python.
  • Provide clear comments in your code.
  • Discuss the time and space complexity of your solution.

As always, we’ll share our solution to this problem tomorrow. Stay tuned 😊