Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Palindrome Without Loops

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

Your question is Palindrome Without Loops. 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

Dayforce may validate employee-facing identifiers that contain spaces, punctuation, and mixed casing. Implement a function that determines whether a text value is a palindrome without using any for loops, while loops, list comprehensions, or generator expressions.

Ignore every character that is not alphanumeric, and compare letters without regard to case. Use recursion to move two pointers inward from the beginning and end of the string.

Formal Specification

Implement is_palindrome(text), where text is a string. Return True if the normalized text reads identically from left to right and right to left. Return False otherwise. An empty string or a string containing no alphanumeric characters is a palindrome.

Constraints

  • 0 <= len(text) <= 2,000
  • text may contain Unicode letters, digits, whitespace, and punctuation
  • Ignore all characters for which isalnum() returns False
  • Comparison is case-insensitive
  • Loops, comprehensions, and generator expressions are not allowed

Function Signature

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