Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Palindrome Check Coding

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

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

Housecall Pro stores short service notes that may need basic text validation before appearing in a customer-facing surface. Given a string, determine whether it is a palindrome, meaning it reads exactly the same from left to right and right to left.

The comparison is case-sensitive, and every character, including spaces and punctuation, must be considered. Return True if the string is a palindrome and False otherwise.

Formal Specification

Implement is_palindrome(s), where s is a string. Return a boolean.

Use a two-pointer approach: compare characters from the beginning and end, moving toward the center. You may assume the input contains only standard ASCII characters.

Constraints

  • 0 <= len(s) <= 100,000
  • s contains standard ASCII letters, digits, spaces, or punctuation
  • The comparison is case-sensitive
  • An empty string is considered a palindrome

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