Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Implement Palindrome Check

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

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

As part of a Boston Scientific Gruppe device-label validation utility, determine whether a string is a palindrome. A string is a palindrome when its characters appear in exactly the same order from left to right and right to left. Comparison is case-sensitive, and spaces and punctuation are treated as ordinary characters.

Implement is_palindrome(s) and return True if s is a palindrome, otherwise return False.

Formal Specification

  • Input: s, a string containing zero or more printable characters.
  • Output: A boolean indicating whether s is a palindrome.
  • Do not create a reversed copy of the string unless using the alternative approach.

Constraints

  • 0 <= len(s) <= 10^5
  • s contains printable characters only
  • Comparison is case-sensitive
  • Spaces and punctuation are treated as ordinary characters

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