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

Palindrome Detection Coding

EasyPython

Problem

During LTTS quality engineering validation, test identifiers may contain spaces, punctuation, and mixed case. Write a function that returns whether an identifier is a palindrome after ignoring non-alphanumeric characters and letter case.

A palindrome reads identically from left to right and right to left after normalization. For example, "No lemon, no melon" is a palindrome because its normalized form is "nolemonnomelon".

Formal Specification

Implement is_palindrome(text).

  • Input: text, a string containing letters, digits, spaces, and punctuation.
  • Output: A boolean. Return true when the normalized string is a palindrome, otherwise return false.

Do not build a separate normalized string. Compare characters in place using two pointers.

Constraints

  • 0 <= len(text) <= 100,000
  • text contains printable ASCII characters
  • Comparison ignores case and non-alphanumeric characters
  • Empty and punctuation-only strings return true

Function Signature

def is_palindrome(text):
Interviewer

Your question is Palindrome Detection Coding. 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.