Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Palindrome Checking Algorithm

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

Your question is Palindrome Checking Algorithm. 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

Change Healthcare systems may receive short identifier strings that require basic validation before processing. Given a string s, determine whether it is a palindrome, meaning it reads the same from left to right and right to left.

Compare characters exactly. The comparison is case-sensitive, and spaces, punctuation, and other characters are part of the string.

Formal Specification

Implement is_palindrome(s), where:

  • Input: s, a non-null string.
  • Output: Return True if s is a palindrome; otherwise, return False.

Use a two-pointer approach that compares characters from the beginning and end while moving toward the center.

Constraints

  • 0 <= len(s) <= 10^5
  • s contains printable ASCII characters
  • Comparison is case-sensitive
  • Spaces and punctuation are significant

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