Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Coding Challenge: Palindrome

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

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

Medtronic CareLink may display alert or status text containing spaces, punctuation, and mixed capitalization. Write a function that determines whether the meaningful characters form a palindrome.

A string is a palindrome if it reads identically from left to right and right to left after converting letters to lowercase and ignoring every non-alphanumeric character.

Formal Specification

Implement is_palindrome(s), where s is a string. Return True if the normalized string is a palindrome, otherwise return False. Normalization must preserve digits, compare letters case-insensitively, and ignore spaces, punctuation, and other non-alphanumeric characters.

Use a two-pointer approach that scans inward from both ends. Avoid constructing a separate normalized string.

Constraints

  • 0 <= len(s) <= 2 * 10^5
  • The input may contain letters, digits, whitespace, and punctuation.
  • Comparisons are case-insensitive.
  • Python's isalnum() determines which characters are alphanumeric.

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