Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Palindrome Check
00:00
5 left

Palindrome Check

EasyPython

Problem

Dell PowerStore asset labels are checked for mirrored identifiers during a validation workflow. Given a string label, determine whether it is a palindrome after ignoring letter case and all non-alphanumeric characters.

A palindrome reads the same from left to right and right to left after normalization. For example, "A man, a plan, a canal: Panama" is a palindrome because its normalized form is "amanaplanacanalpanama".

Formal Specification

Implement is_palindrome(label).

  • Input: label, a string containing letters, digits, spaces, and punctuation.
  • Output: Return true if the alphanumeric characters in label, compared case-insensitively, form a palindrome. Otherwise return false.

Use a two-pointer scan. Do not build a separate normalized string.

Constraints

  • 0 <= len(label) <= 100,000
  • label contains printable ASCII characters
  • Compare letters case-insensitively
  • Ignore all non-alphanumeric characters
  • Do not construct a separate normalized string

Function Signature

def is_palindrome(label):
Interviewer

Your question is Palindrome Check. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.