Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Optimized Palindrome Check
00:00
5 left

Optimized Palindrome Check

EasyPython

Problem

Synechron applications may need to validate mirrored identifiers or text values. Write a function that determines whether a given string is a palindrome while using as little additional memory as possible.

A string is a palindrome if it reads the same from left to right and right to left. Comparison is case-sensitive, and every character, including spaces and punctuation, must be considered exactly as provided.

Formal Specification

Implement is_palindrome(s), where:

  • Input: s, a string containing zero or more ASCII characters.
  • Output: A boolean. Return True if s is a palindrome, otherwise return False.
  • The function must run in linear time and use constant auxiliary space. Do not create a reversed copy of the string.

Constraints

  • 0 <= len(s) <= 100,000
  • The string contains only ASCII characters
  • Comparison is case-sensitive
  • Whitespace and punctuation are significant

Function Signature

def is_palindrome(s):
Interviewer

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