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

Detect Palindrome Method

EasyPython

Problem

Verisign tooling may need to validate character patterns in DNS labels. Given a string, determine whether it is a palindrome, meaning it reads the same from left to right and right to left.

Treat uppercase and lowercase characters as different, and compare every character exactly as provided. Return True for a palindrome and False otherwise. The input contains only letters, digits, hyphens, and periods, and no additional normalization is required.

Formal Specification

Implement is_palindrome(text), where text is a non-empty string. Return a Boolean indicating whether text is a palindrome. The comparison must be case-sensitive, and spaces or punctuation, if present, must be treated as ordinary characters.

Constraints

  • 1 <= len(text) <= 10^5
  • text contains printable ASCII characters
  • Comparison is case-sensitive
  • Spaces, punctuation, digits, and hyphens are treated as ordinary characters

Function Signature

def is_palindrome(text):
Interviewer

Your question is Detect Palindrome Method. 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.