Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Palindrome Function in Python

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Palindrome Function in Python. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Celebal Technologies data validation utilities receive identifiers and text fields that may contain spaces, punctuation, and mixed capitalization. Implement a function that determines whether an input string is a palindrome after normalization.

A normalized palindrome is read identically from left to right and right to left after ignoring every non-alphanumeric character and treating uppercase and lowercase letters as equivalent.

Formal Specification

Given a string s, return a Boolean value:

  • Return True if the normalized string is a palindrome.
  • Return False otherwise.
  • Letters and digits are considered alphanumeric.
  • An empty normalized string is considered a palindrome.

Constraints

  • 1 <= len(s) <= 2 * 10^5
  • s contains printable ASCII characters
  • Ignore all non-alphanumeric characters
  • Comparison is case-insensitive
  • An empty normalized string is considered a palindrome

Function Signature

def is_palindrome(s):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output